2012-02-03 65 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