2014-09-11 57 views
0

我想要在頁面中心並排顯示兩個圖像。我的身體寬度是800px。在IE 8中不是並排顯示圖像,但在IE 11和Firefox中可以正常顯示

在Firefox 31.0,Firefox 20和IE 11中,圖像以這種方式顯示,但在IE 8中,圖像垂直堆疊,水平居中,每邊大約190px的垂直空白帶。

我認爲這可能是由於當並排寬度接近800px時,IE 9可能會將它們包裹起來以便垂直堆疊。我嘗試了300像素以下的圖像,它們仍然在IE中垂直堆疊。

所有建議領受

<div class="gearSection" style="text-align:center;display: block;"> 
    <div style="border:1px solid blue; display:inline-block; margin-left:auto; margin-right:auto;margin-top:2px;margin-bottom:2px;"> 
    <img src="images/Hoodie_02.jpg" border="0" width="380px" height="633px" alt="Hoodie"><br><b>Hoodies</b> 
    </div> 

    <div style="border:1px solid blue; display:inline-block; margin-left:auto; margin-right:auto;margin-top:2px;margin-bottom:2px;"> 
    <img src="images/Hat_02.jpg" border="0" width="380px" height="633px" alt="Hat"><br><b>Beanie Hat</b> 
    </div> 
</div> 
+1

也許嘗試此[鏈接](http://stackoverflow.com/questions/9110646/ie8-display-inline-block-not-working)它談論陳述了''和使用'display:inline-block' – DavidT 2014-09-11 11:41:56

回答

0
You just only need to add <!DOCTYPE html> because of html5 support. Try to read this http://msdn.microsoft.com/en-us/library/ie/ms535242(v=vs.85).aspx 

<!DOCTYPE html> 
<html> 
<head> 
<body> 
<div class="gearSection" style="text-align:center;display: block;"> 
    <div style="border:1px solid blue; display:inline-block; margin-left:auto; margin- right:auto;margin-top:2px;margin-bottom:2px;"> 
    <img src="images/Hoodie_02.jpg" border="0" width="380px" height="633px" alt="Hoodie"><br><b>Hoodies</b> 
    </div> 

    <div style="border:1px solid blue; display:inline-block; margin-left:auto; margin-right:auto;margin-top:2px;margin-bottom:2px;"> 
    <img src="images/Hat_02.jpg" border="0" width="380px" height="633px" alt="Hat"><br><b>Beanie Hat</b> 
    </div> 
</div> 
</body> 
</html> 
+0

David&Ronnie original是<!DOCTYPE HTML PUBLIC「 - // W3C // DTD HTML 4.01 Transitional // EN」>'試過建議'<!DOCTYPE html PUBLIC「 - // W3C // DTD XHTML 1.0 Transitional // EN「」http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd「>'這將圖像並排放置,但許多錯誤與[鏈接] (http://validator.w3.org/)**鏈接的形式**結束標記的驗證符省略,但OMITTAG否被指定**嘗試了<!DOCTYPE html>'這個定位的圖像並排獲取錯誤表單驗證程序**使用CSS代替**使用<!DOCTYPE html>&change是最好的選擇到CSS標記的地方? – user1558796 2014-09-12 19:26:29

0

我相信這是一個重複這個question正如我在上面的註釋說明。您可以嘗試通過在文檔中添加DOCTYPE來解決此問題中的建議。沒有看到你的完整的HTML,我看不出你是否已經有了。如果沒有,添加

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
相關問題