Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

get CSS inset box-shadow to appear on top of inner backgrounds

Tags:

css

I want a CSS inset box-shadow to appear on top of the elements inside of the container with the box-shadow, specifically background colors of child-elements.

Demo: http://jsfiddle.net/Q8n77/

<div class="parent">
    foo
    <div class="content">bar</div>
</div>

<style>
.parent {
    box-shadow : inset 0 0 5px 0 black;
}

.content {
    background : #EEE;
}
</style>

Any ideas? Can do whatever with the HTML, but need to be able to click-through, so no 100% width/height DIVs on top of everything.

like image 772
Nobody Avatar asked Jul 12 '11 00:07

Nobody


People also ask

How do you get rid of shadows on the bottom of a box?

Not possible, because box-shadow is generated based on the entire boundary of the element — you can't select which boundaries you don't want the shadow to be computed... unless you are willing to set a negative offset on the y-axis.

How do you add a box shadow only to the bottom?

Use the box-shadow Property to Set the Bottom Box Shadow in CSS. We can use the box-shadow property to set the shadow only at the bottom of the box. The box-shadow property sets the shadow of the selected element.


1 Answers

If all you need is to have the inset shadow show through background colors, you can use transparent rgba (or hsla) colors rather than hex codes;

.parent {
    box-shadow: inset 0 0 5px 0 black;
}

.content {
    background-color: rgba(0, 0, 0, .2); /* .2 = 20% opacity */
}

Demo at http://jsfiddle.net/Q8n77/7/

like image 114
xec Avatar answered Sep 28 '22 10:09

xec