2011-11-23 46 views
0

非常簡單的HTML:DIV裏面DIV - 在IE7新線

<div id="wrapper" style="background-color:green;">WRAP 
<div style="float:right;">float2</div> 
</div> 

結果:

    在Chrome,IE8,IE9
  • :單詞 「WRAP」,並在 「FLOAT2」 位置同一條線;在IE7中,兩個字和整行都具有綠色BG
  • :第一行爲「WRAP」位置,並具有綠色的BG; 在第二行字「float2」的位置,並有白色BG

所以 - 我想要的:IE7的行爲== IE8/9/Chrome的行爲。

+3

把WRAP之前的內部div – Matijs

回答

1

你只需要翻轉你的元素的順序,使IE可以浮動內之前的div以顯示文本:

<div id="wrapper" style="background-color:green;"> 
    <div style="float:right;">float2</div> 
    WRAP 
</div> 
+0

你是絕對正確的,非常感謝! – Smarty

-1

試試這個:

<div id="wrapper" style="background-color:green;">WRAP<div class="floater" style="float:right;">float2</div></div> 

(刪除空格和換行也許會有所幫助;)

+0

當然,它不會幫助。並且我的啓動消息中的代碼僅用於3行,僅用於stackoverflow,實際代碼恰好佔用1行。 – Smarty

+0

恩,對不起,ie7是越野車,它是頻繁的錯誤。也許嘗試在浮動div後添加clearfix? – vonsko