I don't understand why, but an inset box shadow is beneath my content.
Here's an example:
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.
div {
height:300px;
color:red;
position:relative;
}
div div {
box-shadow:inset 0 0 10px black;
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
}
<div>
<div></div>
a
</div>
Edit:
Alternatively, you can use a pseudo element:
div {
height:300px;
color:red;
position:relative;
}
div:before {
content:'';
display:block;
box-shadow:inset 0 0 10px black;
position:absolute;
top:0;
left:0;
width:100%;
height:100%;
}
<div>
a
</div>