For more background on CSS Image Effects, you can check out my blog series here, or watch my video from CSS Conf EU, which gives a baseline on blend modes and filters.
Simply put, CSSgram is a library for editing your images with Instagram-like filters directly in CSS. What we're doing here is adding filters to the images as well as applying color and/or gradient overlays via various blending techniques to mimic these effects. This means less manual image processing and more fun filter effects on the web!
We are using pseudo-elements (i.e. :after) to create the filter effects, so you must apply these filters on a containing element (i.e. not a content-block like <img>. The recommendation is to wrap your images in a <figure> tag. More about the tag here.
There are currently 2 ways to consume this library:
When using CSS classes, you can simply add the class with the filter name to the element containing your image.
<link rel="stylesheet" href="css/vendor/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: <link rel="stylesheet" href="css/vendor/aden.min.css">, if you're just using one of the styles.
class="aden"class="reyes"class="perpetua"class="inkwell"class="toaster"class="walden"class="hudson"class="gingham"class="mayfair"class="lofi"class="xpro2"class="_1977"class="brooklyn"@extendsIf 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 😊.
scss/cssgram.scss via an import statement in your Sass manifest file (i.e. main.scss). It may look like: @import 'vendor/cssgram';@extend %aden; in your element.For example:
<!-- HTML -->
<figure class="viz--beautiful">
<img src="../img.png">
</figure>
// Sass
.viz--beautiful {
@extend %aden;
}
Alternatively, you can just download and link any individual .scss file in your Sass manifest: scss/aden.scss), if you're just using one of the styles.
@extend %aden;@extend %reyes;@extend %perpetua;@extend %inkwell;@extend %toaster;@extend %walden;@extend %hudson;@extend %gingham;@extend %mayfair;@extend %lofi;@extend %xpro2;@extend %_1977;@extend %brooklyn;