Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to remove image padding that is showing up unintentionally?

Tags:

html

css

web

I have three images in a container that should be stacked seamlessly, but there is some padding occurring between them.

You can see the page here: http://www.arbitersoflight.net/media/

The three large buttons in the container on the left are the ones in question.

Here's the code for the container:

CSS

#mainBoxFull {
    background-image: url(/img/cont/mainfull.jpg);
    float: left;
    height: 560px; 
    width: 560px; 
    margin: 0px; 
    padding: 20px;
}

HTML

<div id="mainBoxFull">
    <img src="/img/btns/media/bgal.jpg" alt="screenshot" width="560" height="180" border="0" />
    <img src="/img/btns/media/bvid.jpg" alt="videos" width="560" height="200" border="0" />
    <img src="/img/btns/media/bsoon.jpg" alt="coming soon" width="560" height="180" border="0" />
</div>
like image 787
Ferret Avatar asked Jan 21 '11 14:01

Ferret


People also ask

How can the gap under the image can be removed?

Display Property: The most commonly used solution is used to change the display property of the <img> tag inside the <div> container from default 'inline' value to 'block' using display : block property.

How do I get rid of body padding in HTML?

All you need to do is give your HEADER tag a 1px border, aswell as setting the BODY MARGIN to zero, as shown below. You may also need to change the MARGIN to zero for any H1, H2, etc. elements you have within your HEADER div. This will get rid of any extra space which may show around the text.


2 Answers

The problem is, that images are inline-blocks. That is, spaces between them are counted. These spaces occur as padding to you. Use

#mainBoxFull img { display: block; }

and the problem should vanish. Alternatively, you can remove the white space in the source HTML between the div and the img elements (all white space).

like image 68
Boldewyn Avatar answered Nov 09 '22 23:11

Boldewyn


Another option to resolve the same problem is

#mainBoxFull{ font-size:0; }

it'll ignore all the white spaces in between. + you can se font size where ever you have the text.

like image 23
user3016780 Avatar answered Nov 09 '22 22:11

user3016780