css div 如何让宽度自动调整,使其充满格。

<div class="dd">
<div class="divt1">
<asp:DropDownList ID="DropDownList1" runat="server"></asp:DropDownList>
</div>
<div class="divt2">
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
</div>
</div>
有应该DropDownList和一个TextBox放在div class=“dd”的一行里,dd的宽度为400px。
DropDownList绑定到不同数据源,所以宽度不固定,
让显示时,DropDownList根据数据源宽度自动调整,剩下的宽度全部用来显示TextBox,而不管textbox中有多少内容。
如何调整TextBox 的宽度?

要达到这种效果最好用表格做,一行两列的表格

<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td width="10%" nowrap="nowrap">DropDownList根据数据源宽度自动调整</td>
<td>TextBox</td>
</tr>
</table>
width="10%" 设置的宽度值,nowrap="nowrap" 使该列宽度超出亦不换行,自适应宽度向后一列挤压。
温馨提示:答案为网友推荐,仅供参考
第1个回答  2015-08-11
1. 计算格式化内容时除了发生明确的换行外不发生换行的时首选宽度(preferred width),以及首选最小宽度(preferred minimum width),比如,尝试所有可能的换行。而CSS2.1没有定义精确的算法。
2. 其次,在这种情况下,找出可用宽度(available width),这个宽度为包含块减去“margin-left”、“border-left-width”、“padding-left”、“padding-right”、“border-right-width”、“margin-right”以及所有相关滚动条的宽度。
第2个回答  2013-10-03
宽度要自行调整需要使用到js,如果不使用估计也行只不过相当之麻烦。不大现实。。。