Reputation: 3289
I am facing an issue to add a box-shadow only on left and right on multiple divs.
I have tried this method already. This is an example of what I want, but it only works for a single div and did not help me out.
My code has several main blocks. I.e.
<div>
<div class="main"></div>
</div>
<div>
<div class="main"></div>
</div>
I need to add box shadow to main block css code
.main:before {
box-shadow: -15px 0 15px -15px inset;
left: -15px;
}
.main:after {
box-shadow: 15px 0 15px -15px inset;
right: -15px;
}
.main { width: 980px; max-width: 1200px; margin: 0 auto; position: relative; background:#fff; padding: 0 25px; }
Wrapper has full width.
Upvotes: 2
Views: 124
Reputation: 346
Try this css
div{margin: 20px; width: 400px; height: 400px;
-webkit-box-shadow: 4px 2px #222, -4px 0 2px #222;
-moz-box-shadow: 4px 0 2px #222, -4px 0 2px #222;
box-shadow: 4px 0 2px #222, -4px 0 2px #222;
}
Upvotes: 0
Reputation: 71140
Like this?
CSS
.main:before {
box-shadow: -15px 0 15px -15px inset;
content: " ";
height: 100%;
left: -15px;
position: absolute;
top: 0;
width: 15px;
}
.main:after {
box-shadow: 15px 0 15px -15px inset;
content: " ";
height: 100%;
position: absolute;
right: -15px;
width: 15px;
}
.main {
background: none repeat scroll 0 0 #EEEEEE;
height: 100px;
margin: 50px;
position: relative;
width: 100px;
}
Upvotes: 3
Reputation: 157304
That's too much mess, why not try this? I just got rid of the :before
and :after
pseudo as well..
Demo 2 (Multiple elements)
div {
background: none repeat scroll 0 0 #EEEEEE;
height: 100px;
margin: 50px;
position: relative;
width: 100px;
box-shadow: 0 10px 0px 0px #eee,
0 -10px 0px 0px #eee,
10px 0 13px -5px rgba(0, 0, 0, 0.5),
-10px 0 13px -5px rgba(0, 0, 0, 0.5);
}
Upvotes: 2