Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make an image have padding while keeping the webkit-box-shadow?

Tags:

css

webkit

I want to style all of the images on my website to have box-shadows and padding of 10px, so that text isn't smooshed up against them. However, when I assign any padding to "img" with CSS, the box-shadow is drawn at the edge of the padding, leaving a 10px blank space around the image.

#content img {
    -moz-box-shadow: 0 0 5px 2px #282a2d;
    -webkit-box-shadow: 0 0 5px 2px #282a2d;
    padding:10px
}

This particular image is floated left within the paragraph. here is an example of my problem -

enter image description here

Any ideas?

EDIT: I do not want the padding. I just want the box-shadow, and then space, so that text doesn't mash up right next to the box-shadow. Turns out what I wanted was margin, not padding. Silly mistake.

like image 895
cjmabry Avatar asked Apr 16 '12 05:04

cjmabry


1 Answers

use margin in addition to padding

#content img {
    box-shadow: 0 0 5px 2px #282a2d;
    padding: 10px;
    margin-right: 10px;  
}
like image 137
zellio Avatar answered Sep 23 '22 17:09

zellio