I don't understand why, but an inset box shadow is beneath my content.
Here's an example:
div {
box-shadow:inset 0 0 10px black;
height:300px;
color:red;
}
<div>
a
</div>
You see the a
is on top of the box shadow.
How can I get the box shadow to be on top of the a
?
You need to make a new element inside the div, with absolute positioning and height and width of 100%, then give that element the box shadow.
HTML:
CSS:
Here is a JSFiddle.
Edit:
Alternatively, you can use a pseudo element:
HTML:
CSS:
JSFiddle.
This answer offers the most straightforward solution via a minimal example and addresses the issue of scrolling.
Unfortunately there is no way to avoid an extra wrapping
div
(due tobox-shadow
layering).