2012-02-27 37 views
2

我试图将两个图像彼此对齐。在IE8 +和FF中,它们对齐正确。在Internet Explorer 7中,无论我使包含图像#1和#2的左侧div有多小,图像#3都会被压低。在IE7中水平对齐图像的问题

的jsfiddle:http://jsfiddle.net/bD87z/4/

<div style="width: 490px; padding-left: 15px; padding-right: 15px; background-color: #000; padding-bottom: 10px; "> 
    <div id="header"> 
     <div id="imageLeftContainer"> 
     <div id="image1" style=""></div> 
     <div style="margin-top: 7px;"> 
     <a href="http://www.google.com" target="_blank" style="text-decoration: none;"><img src="http://i40.tinypic.com/a40ntg.png" style="margin: 0; padding: 0; border: none;" /></a> 
     </div> 
    </div> 
    <a href="http://www.google.com" target="_blank" style="text-decoration: none;"><img id="image3" src="http://i41.tinypic.com/n5mzxi.png" /></a> 
    </div> 
</div> 

CSS:

#header 
{ 
clear: both;  
} 

#imageLeftContainer 
{ 
width: 292px; 
display: inline-block; 
margin: 0; 
padding: 0; 
margin-top: 20px; 
zoom:1; 
*display: inline; 
_height: 100%;   
} 

#image1 
{ 
width: 292px; 
height: 64px; 
margin: 0; 
padding: 0; 
margin-top: 5px; 
background: url(http://i40.tinypic.com/2z8w4uc.png); 
} 

#image3 
{ 
float: right; 
width: 185px; 
height: 108px; 
margin: 0; 
padding: 0; 
margin-top: 15px; 
border: none; 
} 
+0

现在告诉我谁的心情和耐心跟进你完全搞砸代码。首先让一些可读的HTML和CSS分离出来,然后我们可以谈谈。 – 2012-02-27 16:29:32

+0

这些内嵌样式融化了我的眼睛。 – JKirchartz 2012-02-27 16:31:13

+0

我的歉意 - 我现在更新了jsFiddle @SvenBieder。 – 2012-02-27 16:36:22

回答

2

如果你把在div一个float:left包含图像1和图像2。然后把float:right<a>标签上的图像3,它工作正常

的jsfiddle - >http://jsfiddle.net/bD87z/3/

+0

这是有效的,但随后他们浮出他们的容器,#头,我失去了控制#header的垂直边缘。那么我如何包含它们? – 2012-02-27 16:40:37

+0

不知道你的意思。在我的例子中,除非你看到完整的例子,否则一切看起来都很好。否则,我无法进一步帮助 – Henesnarfel 2012-02-27 18:23:41