Box-shadow Only On Right And Left
Solution 1:
You will need to use two box-shadows one for the left shadow and one for the right one. You need to specify both box-shadows in the same box-shadow attribute and seperate them with a coma :
box-shadow: -60px0px100px -90px#000000, 60px0px100px -90px#000000;
Both need to have a negative spread value so they are shorter than the divs height and don't overflow on the top and bottom.
output :
You will need to tweak the values of the shadow in order to adapt it to the size of the element you want to use it on.
HTML :
<div></div>
CSS :
div{
height:500px;
width:300px;
margin:0 auto;
box-shadow: -60px0px100px -90px#000000, 60px0px100px -90px#000000;
}
Solution 2:
You're going to need to go to use images for your shadow. What I mean is, the left and right 'shadows' are going to need to be two images that you can then position on the edges of your div to create the effect. Obviously I didn't test this and it might need a little tweaking, but you'll need to do something like this:
<style>.weird-image{
height: 100px;
width:100px;
position: relative; /* do this so the absolutely positiond imgs are relative to this container */
}
.weird-image-left-shadow{
position: absolute; /*positioned relative to .weird-image*/top: 0px; /*align img with top of div*/left:-15px; /* some negative value so that the shadow goes on the outside of div*/
}
.weird-image-right-shadow{
position: absolute; /*positioned relative to .weird-image*/top: 0px; /*align img with top of div*/right:-15px; /* some negative value so that the shadow goes on the outside of div*/
}
</style><divclass="weird-image"><imgclass="weird-image-left-shadow"src="left-shadow.png"/><imgclass="weird-image-right-shadow"src="right-shadow.png" /><p>My Actual Div Content</p></div>
Solution 3:
I think the most elegant semantical way must be to wrap that element inside a div, with overflow-y: hidden;
and padding: 0 [horizontal-spread-box-shadow]
. Here is the exaggerated example:
body {
padding: 50px;
}
.parent {
display: inline-block;
border: 2px solid red;
overflow-y: hidden;
padding: 040px;
}
.children {
width: 100px;
height: 100px;
box-shadow: 0040px#000;
background: blue;
}
<divclass="parent"><divclass="children"></div></div>
Post a Comment for "Box-shadow Only On Right And Left"