How to set inner shadow on text in CSS (in webkit…)
Unlike the box-shadow property, inner-shadow does not support theinset attribute. The following code is NOT valid:
Which is a bummer, I really wanted to style the logo of my site in CSS and not use an image, font or SVG for it. But I came over a clever hackthat solves the issue for us.
How it works
There are 5 steps that are needed to acheive this, and you can see the result of each of them below:
How it works:
- The normal style without any applied effects
- The text when a black shadow with opacity applied
- We hide the text the only thing visible is the shadow
- We set the background color to the color we want the text in
- We clip the background to the bounds of the text. This will make the shadow look like it is just on the inside of the text!
Support
Background is a webkit specific property at this point.
UPDATE: Turns out it is tricky to feature test this unless you want to browsersniff. Modernizr has not yet found a good solution:https://github.com/Modernizr/Modernizr/issues/199
Happy coding!