2012-02-03 10 views
1

下面的代碼做的伎倆可能會顯示在Internet Explorer中的同一行兩個div:的div上的tableHeader同一線上

<html> 
<head> 
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> 
<style> 
    th 
    { 
     border: 0px solid; 
     font :12px/1.3 "Lucida Grande", Arial, sans-serifw; 
     font-weight: bold; 
     padding-left: 5px; 
     padding-right: 5px; 
     background :lightgrey; 
     clear :both; 
     width: 70px; 
    } 
    .thspan 
    { display: inline; 
     float :left; 
     word-wrap: break-word; 
     margin-right 25px; 
    } 
    .bspan 
    { display: inline; 
     float: right; 
     width: auto; 
    } 
</style> 
</head> 
    <body> 
     <table> 
      <th> 
       <div class="bspan"><button id="text2"></button></div> 
       <div class="thspan">text1dskjsdkjfsd-sdfdsf</div> 
      </th> 
     </table> 
    </body> 
</html> 

但現在不會在Chrome和Firefox ...任何人合作一個想法爲什麼?

感謝

回答

1

嘗試改變。 thspan謊言低於

添加保證金的權利,擺脫了浮動和變化顯示的阻止

.thspan { 
     display: block; 
     word-wrap: break-word; 
     margin-right: 20px; 
} 
+0

哇,那實際上工作:)。謝謝。只有一個小問題。在Internet Explorer中,按鈕的右邊也會有一個20px的邊界(僅當文本非常長時)(在chrome和firefox中,情況並非如此)。任何想法是什麼造成的? – 2012-02-03 13:58:52

0

我認爲這只是你的「日」是不夠寬,試試這個:

th{ 
width: 160px; 
} 
+0

這是正確的,但CSS的目的應該是當寬度有限時,顯示到彼此旁邊的包裝文本和按鈕。 – 2012-02-03 12:46:49

0

嘗試使用display : inline-table爲的DIV

+0

對不起,這不是解決問題 – 2012-02-03 12:45:28

0

這工作

<html> 
<head> 
    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1"> 
<style> 
    th 
    { 
     border: 0px solid; 
     font :12px/1.3 "Lucida Grande", Arial, sans-serifw; 
     font-weight: bold; 
     padding-left: 5px; 
     padding-right: 5px; 
     background :lightgrey; 
     clear :both; 
     width: auto; 
     display: inline; 
    } 
    .thspan 
    { display: inline; 
     word-wrap: break-word; 
     margin-right 25px; 
    } 
    .bspan 
    { display: inline; 
     width: auto; 
    } 
    #text2 
    { 
     display:inline; 
    } 
</style> 
</head> 
    <body> 
     <table> 
      <th> 
       <div class="bspan"><button id="text2"></button></div> 
       <div class="thspan">text1dskjsdkjfsd-sdfdsf</div> 
      </th> 
     </table> 
    </body> 
</html> 
+0

你可以試試這個,並且首先感謝 – iblazevic 2012-02-03 13:47:02

+0

iblazevic感謝你的所有努力!上面的工作確實只有th寬度將由它下面的列中的值的寬度來設置,所以我不能使用auto作爲它。 – 2012-02-03 13:53:53

+0

沒問題,也許你下次會幫我,你可以檢查你的問題,因爲他們不在未回答列表中 – iblazevic 2012-02-03 14:19:59