CSS - Filters - How to combine

In Summary

This example demonstrates using CSS Filters on the parent div, to transform all contained elements, including border, image, background color and text.

How to combine Contrast & Grayscale.

[the-hare.gif]
The hare takes aim

CSS

div.example {
    filter: contrast(150%) grayscale(100%);
}

Syntax filter: filter-function(params) filter-function(params);

Note: CSS Filters are not supported by Internet Explorer.

Step by Step

Original Image
No filter
[the-hare.gif]
The hare takes aim

HTML

Simplified
<div class="example">
    <figure>
        <img src="images/the-hare.gif" />
        <figcaption>The hare takes aim</figcaption>
    </figure>
</div>

CSS

div.example {
}
contrast
[the-hare.gif]
The hare takes aim

CSS

div.example {
    filter: contrast(150%);
}

Syntax contrast(number | percent);

grayscale
[the-hare.gif]
The hare takes aim

CSS

div.example {
    filter: grayscale(100%);
}

Syntax grayscale(number | percent);

Combined
Contrast +
Grayscale
[the-hare.gif]
The hare takes aim

CSS

div.example {
    filter: contrast(150%) grayscale(100%);
}

Syntax filter: filter-function(params) filter-function(params);



Ads by Google


Ask a question, send a comment, or report a problem - click here to contact me.

© Richard McGrath