Effects
filter
filter applies image effects such as blur, brightness, and hue rotation to everything an element draws, children included. List several functions separated by spaces.
Syntaxnone | <filter-value-list> …
none | <filter-value-list>
<filter-value-list> = [ <filter-function> | <url> ]+
<filter-function> = <blur()> | <brightness()> | <contrast()>
| <drop-shadow()> | <grayscale()> | <hue-rotate()>
| <invert()> | <opacity()> | <saturate()> | <sepia()>Preview
Presets
Drag the bottom-right corner to resize
Code
.box {
background: linear-gradient(
135deg,
#88d1c7,
#77a7d7,
#eaac3a
);
border-radius: 24px;
filter: hue-rotate(90deg) drop-shadow(0 8px 12px #0f172a40);
}Controls
hue-rotate(90deg)
<angle>
drop-shadow(0 8px 12px #0f172a40)
offset-x
offset-y
blur-radius
color
Add a function
About
The functions
blur()blurs. The radius is a length;%is not allowed.brightness(),contrast(), andsaturate()leave the image as is at1(100%), weaken it below, and strengthen it above.grayscale(),sepia(),invert(), andopacity()take an amount from0to1(0%to100%). Anything above1counts as1.hue-rotate()turns the hue by an angle;360degcomes full circle.- With no argument,
blur()uses0,hue-rotate()uses0deg, and the rest use1. Sograyscale()and friends apply at full strength when the argument is left out.
Applied in order
Functions apply from left to right. Adding a shadow and then going grayscale (drop-shadow(0 8px 12px red) grayscale(1)) turns the shadow gray too, while the reverse order keeps it red. Reorder the cards in the controls to see it.
drop-shadow() vs. box-shadow
drop-shadow() follows the shape of the drawn pixels, so it hugs images with transparency and cut-out shapes. Unlike box-shadow, it has no spread and no inset. Change the background in the code to radial-gradient(circle, #77a7d7 40%, transparent 41%) and the shadow follows the circle.
Watch out
- Any value other than
nonemakes the element a new stacking context and the containing block forposition: fixeddescendants. If a fixed modal suddenly moves, check its ancestors forfilter. - To blur what is behind an element, use
backdrop-filterinstead offilter.