CSS Visual Effects
Visual effects in CSS let you fade, blur, and blend elements without using images or JavaScript. They’re widely used in modern UI/UX design to create soft, interactive, and immersive visuals.
๐น opacity and visibility
These control whether an element is visible and how transparent it is.
โ
opacity
Defines transparency (range: 0 = fully transparent, 1 = fully opaque).
.box {
opacity: 0.5; /* 50% transparent */
}๐ก You can transition
opacityfor smooth fade effects.
โ
visibility
Toggles visibility without affecting layout.
.box {
visibility: hidden; /* Still takes up space */
}| Property | Hides Element? | Removes from layout? |
|---|---|---|
opacity: 0 | โ Yes | โ No |
visibility: hidden | โ Yes | โ No |
display: none | โ Yes | โ Yes |
๐น filter
The filter property lets you apply visual effects directly on elements, like blur, brightness, contrast, and more.
โ Common Filters:
img {
filter: blur(4px);
}
.card {
filter: brightness(1.2);
/* Other options:
contrast(1.5)
grayscale(1)
sepia(0.7)
saturate(2)
hue-rotate(45deg)
invert(1)
*/
}You can combine multiple filters:
img {
filter: blur(2px) brightness(1.2) contrast(1.1);
}๐ฏ Tip: Works great on images, backgrounds, buttons, and even text.
๐น mix-blend-mode
This controls how an element blends with the background below it, similar to Photoshop blending modes.
โ Example:
.image {
mix-blend-mode: multiply;
}โ Popular Blend Modes:
| Mode | Description |
|---|---|
normal | Default |
multiply | Darkens based on background |
screen | Lightens the image |
overlay | Mix of multiply & screen |
difference | Inverts colors |
soft-light | Subtle light effect |
๐จ Blend modes work well for image overlays, hover effects, and creative designs.
๐น backdrop-filter
Applies filters to the background behind an element (great for glassmorphism).
โ Example:
.glass {
backdrop-filter: blur(10px) brightness(1.2);
background-color: rgba(255, 255, 255, 0.3);
}โ ๏ธ Requires
background-colorwith transparency and may need:
.glass {
-webkit-backdrop-filter: ...; /* for Safari */
}โจ Visual Effects in Action
.card {
opacity: 0.9;
filter: brightness(1.1) blur(1px);
mix-blend-mode: soft-light;
backdrop-filter: blur(12px);
background: rgba(255, 255, 255, 0.2);
}โ Summary Covered
opacityandvisibilityfor visibility controlfilterfor blur, brightness, contrast, etc.mix-blend-modefor creative overlaysbackdrop-filterfor glass and blur effects