2012-02-27 36 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