drop-shadow() Filter
drop-shadow() is a CSS filter function that applies a
shadow effect to the rendered image, shape, or element, including its
alpha (transparency) channel. Unlike box-shadow, which is
applied to the element's box, drop-shadow() follows the
visible shape, making it ideal for images with transparency, SVGs, and
icons.
filter: drop-shadow(h-offset v-offset blur color);
Key differences from box-shadow:
drop-shadow() works on the rendered shape (including
transparency), not just the box.
filter property, not as a standalone
property.
drop-shadow() filters can be chained for
layered effects.
Use drop-shadow() to create realistic shadows for
images, icons, and custom shapes, especially when transparency is
involved. Experiment with color and blur for creative effects. For UI
elements like cards or buttons, box-shadow is usually
preferred.
.basic-drop-shadow {
filter: drop-shadow(4px 4px 8px #888);
}
.colored-drop-shadow {
filter: drop-shadow(0 8px 16px #8e44ad);
}
.multiple-drop-shadow {
filter: drop-shadow(2px 2px 4px #3498db) drop-shadow(-2px -2px 4px #ffd200);
}
.interactive-drop-shadow:hover {
filter: drop-shadow(0 8px 24px #f7971e) drop-shadow(0 0 8px #ffd200);
}
.transparent-drop-shadow {
filter: drop-shadow(0 8px 16px #3498db);
}