Lesson 17 of 50
cssCSS Filters
7 mins
Course progress34%
What you'll learn
Keep these ideas in mind as you work through the lesson.
Lesson 17 of 50
css7 mins
Keep these ideas in mind as you work through the lesson.
The filter property applies image‑processing effects directly in the rendering pipeline, similar to Photoshop layers.
| Function | Example | Effect |
|---|---|---|
blur(px) | blur(5px) | Softens the image. |
brightness(%) | brightness(150%) | Makes the element brighter. |
contrast(%) | contrast(200%) | Increases contrast. |
grayscale(%) | grayscale(0.5) | 50 % grayscale. |
hue-rotate(deg) | hue-rotate(90deg) | Shifts hue wheel. |
invert(%) | invert(100%) | Color inversion (good for dark‑mode hacks). |
sepia(%) | sepia(0.7) | Vintage look. |
drop-shadow() | drop-shadow(2px 4px 6px black) | Like box-shadow but respects transparency. |
.card img {
transition:filter .3s ease;
}
.card:hover img {
filter:blur(2px) brightness(0.9);
}
The transition is GPU‑accelerated because filters are applied on the compositor layer in modern browsers.
backdrop-filter – The Glass‑Morphism Trick.glass {
background: rgba(255,255,255,0.2);
backdrop-filter: blur(10px) saturate(180%);
border: 1px solid rgba(255,255,255,0.3);
}
backdrop-filteraffects everything behind the element, giving a frosted‑glass appearance.
Filters on large raster images can be CPU‑intensive. Use them sparingly, limit the area via clip-path, or provide a fallback for low‑power devices.