CSS - Filters

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 {
}
blur
[the-hare.gif]
The hare takes aim

CSS

div.example {
    filter: blur(2px);
}

Syntax blur(length);

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

CSS

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

Syntax brightness(number | percent);

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

CSS

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

Syntax contrast(number | percent);

drop-shadow
[the-hare.gif]
The hare takes aim

CSS

div.example {
    filter: drop-shadow(10px 10px 5px saddlebrown)
}

Syntax drop-shadow(offset-x offset-y shadow-depth color);

Arguments must be space separated. Commas will not work.

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

CSS

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

Syntax grayscale(number | percent);

hue-rotate
[the-hare.gif]
The hare takes aim

CSS

div.example {
    filter: hue-rotate(120deg);
}

Syntax hue-rotate(angle);

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

CSS

div.example {
    filter: invert(1);
}

Syntax invert(number | percent);

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

CSS

div.example {
    filter: opacity(0.5);
}

Syntax opacity(number | percent);

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

CSS

div.example {
    filter: saturate(300%);
}

Syntax saturate(number | percent);

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

CSS

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

Syntax sepia(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