I need to make my box-shadow appear like a border: If I have a parent with a inset boxshadow and I put a child div in it, the box shadow should go over the child div like shown here with borders:
jsFiddle: http://jsfiddle.net/7rRsw/2/
Is there anything like a z index for this problem, or a css hack?
Thanks
EDIT: I need to use box shadow inset + no borders or box seizings. I am searching for hacks to make this possible only with box shadow. A possible hack would be to add box shadows left and right on the child div.
The CSS box-shadow property is used to apply one or more shadows to an element.
Using transforms on the box-shadow (& transform ) property, we can create the illusion of an element moving closer or further away from the user.
In CSS, shadows on the boxes of elements are created using the box-shadow property (if you want to add a shadow to the text itself, you need text-shadow ). The box-shadow property takes a number of values: The offset on the x-axis. The offset on the y-axis.
The blur radius (optional), if set to 0 the shadow will be sharp, the higher the number, the more blurred it will be. The spread radius (optional), positive values increase the size of the shadow, negative values decrease the size.
If you want a solution in which you don't need any extra markup, you can use the ":before" pseudo class selector: http://jsfiddle.net/7rRsw/8/
<div class="a"><div class="b">No extra markup needed</div></div>
.a {
width: 200px;
float: left;
height: 200px;
margin-right: 100px;
background-color: red;
position: relative;
}
.a:before {
content: '';
position: absolute;
left: 0;
right: 0;
width: 200px;
height: 200px;
box-shadow: inset 0px 0px 0px 2px black;
-webkit-box-shadow: inset 0px 0px 0px 2px black;
-moz-box-shadow: inset 0px 0px 0px 2px black;
}
.b {
width: 200px;
height: 100px;
background-color: yellow;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With