4 replies [Last post]
ryy
ryy's picture
User offline. Last seen 2 years 5 days ago. Offline
newbie
Timezone: GMT-4
Joined: 2009-08-18
Posts: 5
Points: 7

Hello,
I've cut up a single image into two and I would like them to sit on top of each other. Unfortunately, I can't get rid of the empty space between the two images even after I set padding and margin to zero. In order to get rid of the empty space I have to use margin-bottom:-10px;

Why does this happen? Please copy and paste the following code and view it on your computer.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
 
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-Type" />
<style type="text/css">
#canvas {
  margin-left: auto;
  margin-right: auto;
  width:969px; 
}
 
#imgCont{
 float:left;
 width:276px;
 height:260px;
}
#imgCont img{
 padding:0;
 margin:0;
 border-top: 1px solid blue;
 border-bottom:1px solid black;
}
</style>
<title>Conforming XHTML 1.1 Template</title>
 
</head>
 
<body>
  <div id="canvas">
   <div id="imgCont"
     <img src="http://goyami.corante.com/archives/images/july4th05.gif" />
 
	 <img src="http://www.logoogle.com/images/logooward/july4th04.gif" />
   </div><!--/#imgCont"-->
  </div><!--/#canvas-->
 
</body>
</html>

Deuce
Deuce's picture
User offline. Last seen 4 weeks 5 days ago. Offline
rank Guru
Guru
Timezone: GMT-5
Joined: 2005-11-20
Posts: 4421
Points: 1840

Why can't you use just one

Why can't you use just one image?

all ยป http://dictionary.reference.com/browse/all

Google isn't a bunch of guys reading and grading web sites, it's more like a bunch of monkeys sniffing food and putting the good bananas at the top. -Triumph

wolfcry911
wolfcry911's picture
User offline. Last seen 24 weeks 2 days ago. Offline
rank Guru
Guru
Timezone: GMT-5
Joined: 2004-09-01
Posts: 3222
Points: 235

#imgCont img {

#imgCont img { vertical-align: bottom; }
or
#imgCont img { display: block; }

ryy
ryy's picture
User offline. Last seen 2 years 5 days ago. Offline
newbie
Timezone: GMT-4
Joined: 2009-08-18
Posts: 5
Points: 7

Deuce wrote: Why can't you

Deuce wrote:

Why can't you use just one image?

Long story short: The bottom image will change.

Thank you both for your prompt responses. Why doesn't margin:0; padding:0; work with inline elements? Could you please explain?

wolfcry911
wolfcry911's picture
User offline. Last seen 24 weeks 2 days ago. Offline
rank Guru
Guru
Timezone: GMT-5
Joined: 2004-09-01
Posts: 3222
Points: 235

http://www.maxdesign.com.au/a