Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS Box-Shadow adds arbitrary white border to Div

Tags:

css

border

I'm adding a box shadow to an element containing an img and it's creating an arbitrary white border on the bottom of the element. No border is being applied via CSS (and I even tried overriding with border:none; without luck). When applied to the image directly, it appears properly. But when applied to a div containing an image, the border appears.

Any help is grealty appreciated.

<style>
html,body,div,img {margin:0; padding:0;} 
body {padding:50px;}

.badge_image {
  float:left;
  /* css drop shadow */
  -webkit-box-shadow: 1px 1px 5px 0px #a2958a;
  -moz-box-shadow: 1px 1px 5px 0px #a2958a;
  box-shadow: 1px 1px 5px 0px #a2958a; 
}
</style>

<div class="badge_image">
    <img src="badge-image.jpg" height="75" width="75" />
</div>  

<br clear="all" /><br clear="all" />

<img src="badge-image.jpg" height="75" width="75" class="badge_image" /><!-- works fine -->
like image 318
johnkeese Avatar asked Sep 16 '25 08:09

johnkeese


1 Answers

try display block for image.

.badge_image img {
    display: block;
}
like image 165
kuyabiye Avatar answered Sep 19 '25 01:09

kuyabiye