我需要设置一个div的宽度动态,因为我有一个动态表格,该div中,当它有太多的列,我不能水平滚动底部栏(不是DIV的一个,浏览器的)。CSS和DIV动态宽度
我在我的HTML文件中得到这个:
<div class="total">
<table border="1">
<tr>
<td>row 1, cell 1</td>
...
<td>row 1, cell m</td>
</tr>
<tr>
<td>row 2, cell 1</td>
...
<td>row 2, cell m</td>
</tr>
...
<tr>
<td>row n, cell 1</td>
...
<td>row n, cell m</td>
</tr>
</table>
</div>
,我有这个在我的CSS:
.total{
position:relative;
top:50px;
margin: 0 auto;
background-color:#eeeeee;
height:auto;
width:auto;
border:2px solid #000;
border-color:rgb(82,115,154);
overflow: hidden;
}
这里有一个与示例的链接我在做什么:
我怎样才能设置 “总” div的宽动态?这必须在IE7浏览器上工作。
你可以使用jQuery。检查这个主题http://stackoverflow.com/questions/1015669/calculate-total-width-of-children-with-jquery – smefju
我不能这样做,只有与CSS? – abierto
我不记得我看到的与此类似的SO问题,但我可以发誓解决方案是在和
元素中将宽度和高度设置为100%。 – huzzah