This content originally appeared on CSS-Tricks and was authored by Chris Coyier
A bona fide CSS trick from Kirupa Chinnathambi here. To match a colored shadow with the colors in the background-image
of an element, you inherit
the background in a pseudo-element, kick it behind the original, then blur and filter it.
.colorfulShadow {
position: relative;
}
.colorfulShadow::after {
content: "";
width: 100%;
height: 100%;
position: absolute;
background: inherit;
background-position: center center;
filter: drop-shadow(0px 0px 10px rgba(0, 0, 0, 0.50)) blur(20px);
z-index: -1;
}
Negative z-index
is always a yellow flag for me as that only works if there are no intermediary backgrounds. But the trick holds. There would always be some other way to layer the backgrounds (like a <span>
or whatever).
For some reason this made me think of a demo I saw (I can’t remember who to credit!). Emojis had text-shadow
on them, which really made them pop. And those shadows could also be colorized to a similar effect.
Direct Link to Article — Permalink
The post Creating Colorful, Smart Shadows appeared first on CSS-Tricks.
You can support CSS-Tricks by being an MVP Supporter.
This content originally appeared on CSS-Tricks and was authored by Chris Coyier
Chris Coyier | Sciencx (2021-05-04T14:19:48+00:00) Creating Colorful, Smart Shadows. Retrieved from https://www.scien.cx/2021/05/04/creating-colorful-smart-shadows-2/
Please log in to upload a file.
There are no updates yet.
Click the Upload button above to add an update.