2011-05-27 73 views
-1

有沒有什麼辦法讓IE7正確解釋CSS,就像在Firefox或其他? 我有寬度+填充div屬性的問題。火狐上的div填充/ IE7

在FF/IE8 + div上自動展開,並且該div的內容居中,但在IE7中div移動到右側,溢出隱藏了其餘內容。看看下面的圖片:

padding preview http://uploadpic.org/storage/2011/D8AHkOOwH8DhIFlogShP0zhPG.jpg

有沒有辦法破解嗎? 一些CSS代碼:

#center { width: 50%; height:auto; position:relative; padding-left:500px; } 
#both { width:1000px; float:right; } 
#content_home { width:698px; margin:0 auto; min-height:400px; 
    float:left; position:relative; } 

和HTML代碼:

<div id="center"> 
    <div id="both"> 
     <div id="content_home"> 
      <p>...</p> 
     </div> 
     <div id="right"> 
      <p>...</p> 
     </div> 
    </div> 
    <div class="clear"></div> 
</div> 
+0

你有活的鏈接嗎? – 2011-05-27 15:49:02

+1

什麼是您的文檔類型(如在您的問題中包括它)? – 2011-05-27 15:54:20

+0

您發佈的代碼不會顯示您描述的行爲。 http://jsfiddle.net/gilly3/xMUVU/。 – gilly3 2011-05-27 15:55:09

回答

0

最好的辦法是針對IE7及以下特定風格,因爲他們錯誤地適用了盒模型。您可以使用條件主體標籤來做到這一點。

在你的CSS
<!-- Conditional CSS include for IE6 and below --> 
    <!--[if lt IE 7 ]><body class='ie6'><![endif]--> 
    <!-- Conditional CSS include for IE7 --> 
    <!--[if IE 7 ]><body class='ie7'><![endif]--> 
    <!-- Conditional CSS include for IE8 --> 
    <!--[if IE 8 ]><body class='ie8'><![endif]--> 
    <!-- Conditional CSS include for IE9 --> 
    <!--[if IE 9 ]><body class='ie9'><![endif]--> 
    <!--[if !IE]>--><body><!--<![endif]--> 

則...

body.ie7{ 
    width:12345px; 
} 
0

不知道這是否會在你的情況下工作,但你試過IE7.js修復?這是一個方便的JavaScript文件,旨在使IE瀏覽器符合標準。這可能值得一試。

http://code.google.com/p/ie7-js/

+0

我試過了,我認爲它可以工作,但是當我上傳文件並在IE7上檢查時,它又發生了。 – Kamil 2011-05-27 18:40:52