Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Box shadow not showing on the top or bottom

Tags:

css

I am developing a site and I am running into an issue towards the bottom with the box-shadows on the three different sections. I want the border to show up around all three, but it only shows on the left and right.

Here is the HTML for that section:

<div class="three-cols-row">

<div class="three-cols-col three-cols">
<p style="text-align: center;"><img src="https://www.lytyx.com/subdomains/test/websites/mynaturerich.com/wp-content/uploads/2013/02/section01.jpg" alt="" /></p>
<p style="text-align: center;">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et. <a href="#">Read More</a></p>

</div>
<div class="three-cols-col three-cols">
<p style="text-align: center;"><img src="https://www.lytyx.com/subdomains/test/websites/mynaturerich.com/wp-content/uploads/2013/02/section02.jpg" alt="" /></p>
<p style="text-align: center;">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et. <a href="#">Read More</a></p>

</div>
<div class="three-cols-col three-cols">
<p style="text-align: center;"><img src="https://www.lytyx.com/subdomains/test/websites/mynaturerich.com/wp-content/uploads/2013/02/section03.jpg" alt="" /></p>
<p style="text-align: center;">Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et. <a href="#">Read More</a></p>

</div>
</div>
<div class="clearboth"></div>

Here is the CSS for that section:

.three-cols-col{ margin:0 16px 0 16px; overflow:hidden; float:left; display:inline; }
.three-cols-row { margin:0 auto; width:960px; overflow:hidden; }
.three-cols-row .three-cols-row { margin:0 -16px 0 -16px; width:auto; display:inline-block; }
.three-cols { width:248px; padding: 15px; background: #fff; -moz-box-shadow: 0 0 3px #d4d4d4;-webkit-box-shadow: 0 0 3px #d4d4d4; box-shadow: 0 0 3px #d4d4d4; }
like image 452
alexhoug Avatar asked Feb 11 '13 18:02

alexhoug


People also ask

How do you apply box shadow only on top and bottom?

essentially the shadow is the box shape just offset behind the actual box. in order to hide portions of the shadow, you need to create additional divs and set their z-index above the shadowed box so that the shadow is not visible.

Why box shadow property is not working?

you have too many numbers in the value of your box-shadow property. Also your navigation is in a paragraph tag… I believe the shadow didn't work because you did not have a set width on the shadow div. You are using extra markup than needed so I condensed and applied the code below for you.

How do I set the box shadow on the bottom only?

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.

How do you get rid of shadow on one side?

1) Set your shadow's horizontal alignment to the left (negative values). box-shadow: -30px 0px 10px 10px #888888; Although this way you won't have the same shadow size in the top and bottom. 2) Use a div inside a div and apply shadow to each one.


1 Answers

You have two choices:

  1. Remove the overflow: hidden from all the parents node, because this is clipping your shadow. In your case, remove it from the following selectors: .row, .column and .three-cols.

  2. You can just add some vertical margin to your: .three-cols-col. Instead of: margin: 0 16px 0 16px; you can just put: margin: 16px 16px 16px 16px;.

Both choices were tested on Google Chrome.

like image 180
Rubens Mariuzzo Avatar answered Sep 21 '22 12:09

Rubens Mariuzzo