Home

Awesome

CSSgram

CDNJS

CSSGram is an Instagram filter library written in Sass and CSS.

What is This?

Simply put, CSSgram is a library for editing your images with Instagram-like filters directly using CSS. What we're doing is adding filters to the images, as well as applying color and/or gradient overlays via various blending techniques to mimic filter effects. This means less manual image processing and more fun filter effects on the web!

We're using pseudo-elements (i.e. ::before and ::after) to create the filter effects, so you must apply these filters on a containing element (i.e. not a replaced element like <img>). The recommendation is to wrap your images in a <figure> tag. More about the tag here.

Browser Support

This library uses CSS Filters and CSS Blend Modes. These features are supported in the following browsers:

<img src="http://i.imgur.com/NjIVmRO.png" width="48px" height="48px" alt="Chrome logo"><img src="http://i.imgur.com/o1m5RcQ.png" width="48px" height="48px" alt="Firefox logo"><img src="http://i.imgur.com/0R5whqc.png" width="48px" height="48px" alt="Internet Explorer logo"><img src="http://i.imgur.com/kQ1e7Mk.png" width="45px" height="45px" alt="Edge logo"><img src="http://i.imgur.com/FSJB8BL.png" width="48px" height="48px" alt="Opera logo"><img src="http://i.imgur.com/yLwF24I.png" width="48px" height="48px" alt="Safari logo">
43+ ✔38+ ✔Nope ✘13 ✔32+ ✔8+ ✔

For more information, check on Can I Use.

Usage

There are currently 2 ways to consume this library:

Use CSS classes

When using CSS classes, you can simply add the class with the filter name to the element containing your image.

  1. Include the CDN link in your <head> tag: <link rel="stylesheet" href="https://cssgram-cssgram.netdna-ssl.com/cssgram.min.css">. We're also on CDNJS which means another option is <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/cssgram/0.1.10/cssgram.min.css">

For example:

<!-- HTML -->
<figure class="aden">
  <img src="../img.png">
</figure>

Alternatively, you can just download and link to any individual css file (e.g. <link rel="stylesheet" href="css/vendor/aden.min.css">) if you're using only one of the styles.

Available Classes

For use in HTML markup:


Use Sass @extend or @mixin

If you use custom naming in your CSS architecture, you can add the .scss files for the provided styles within your project and then @extend the filter effects within your style definitions. If you think extends are stupid, I will fight you 😊.

  1. Download the scss/ folder contents

For example:

<!-- HTML -->
<figure class="viz--beautiful">
  <img src="../img.png">
</figure>
// Sass
.viz--beautiful {
  @extend %aden;
}

or using mixins (more flexible)

// Sass (without adding new CSS3 filters)
.viz--beautiful {
  @include aden();
}

// Sass (adding new CSS3 filters)
.viz--beautiful {
  @include aden(blur(2px) /*...*/);
}

Alternatively, if you're using only one of the styles, you can download and link any individual .scss file in your Sass manifest (i.e. scss/aden.scss).

Available Placeholders

For use in Sass stylesheets:

Extends

Mixins (You can add more CSS3 filters as arguments)

Contributing

Either:

  1. Create an issue

Or:

  1. Fork this repository
  2. Clone the fork onto your system
  3. npm install dependencies (must have Node installed)
  4. Run gulp to compile CSS and the test site
  5. Make changes and check the test site with your changes (see file structure outline below)
  6. Submit a PR referencing the issue with a smile :smile:

Filters are really fun to create! Reference photos created by Miles Croxford can be found here.

File Structure Outline

Note: This will also have mixin options and a PostCSS Component.