2011-09-20 47 views
1

我需要在某段的右側顯示圖像而不使用浮點數。 所以我想出了這個解決方案,它使用display:table來獲得非常相似的結果。顯示問題:FireFox中的表

我的CSS在IE8>上效果很好,但不適用於任何版本的Firefox。

至於我的理解顯示:表應該是FF的support

任何想法我在這裏做錯了,以及如何解決它?由於

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
    <html xmlns="http://www.w3.org/1999/xhtml"> 
    <head> 
     <title></title> 
     <style> 
     .box 
     { 
      display:table; 
      background-color:Yellow; 
      margin:30px 0px 30px 0px; 
     } 
     .box p 
     { 
      background-color:Gray; 
     } 
     .box h2 
     { 

     } 
     .box img 
     { 
      display:table-cell; 
      vertical-align:top; 
     } 
     </style> 
    </head> 
    <body> 
     <div class="box"> 
      <h2> 
       Title 01 here.</h2> 
      <p> 
       Some text 01 here, Some text 01 here, Some text 01 here, Some text 01 here, Some 
       text 01 here, Some text 01 here.</p> 
      <img src="http://crackle.imageshack.us/images/blue/cooltool.png" alt="Angry face" /> 
     </div> 
     <div class="box"> 
      <h2> 
       Title 02 here.</h2> 
      <p> 
       Some text 02 here, Some text 02 here, Some text 02 here, Some text 02 here, Some 
       text 02 here, Some text 02 here.</p> 
      <img src="http://crackle.imageshack.us/images/blue/cooltool.png" alt="Angry face" /> 
     </div> 
    </body> 
    </html> 

回答

2
display:table-cell; 
vertical-align:top; 

意味着對象與display:table-cell;內容被垂直神韻:。

你需要首先在其父圖像中,爲什麼不能使用float?

+0

謝謝解決了這個問題。 – GibboK