ASP.NET中,CheckBoxList里的選擇都是自動(dòng)寬度的,屬性時(shí)沒(méi)有設(shè)置各項(xiàng)寬度的設(shè)置。
參考了一下網(wǎng)上的最小寬度樣式,
復(fù)制代碼 代碼如下:
/* 最小寬度 */
.min_width{min-width:300px;
/* sets max-width for IE */
_width:expression(document.body.clientWidth 300 ? "300px" : "auto");
}
寫(xiě)成如下:
復(fù)制代碼 代碼如下:
style>
.ckblstEffect td
{
min-width:80px;
_width:expression(document.body.clientWidth 80 ? "80px" : "auto");
}
/style>
復(fù)制代碼 代碼如下:
asp:CheckBoxList ID="ckblstEffect" runat="server" DataTextField="MC"
RepeatDirection="Horizontal" RepeatColumns="10" CssClass="ckblstEffect"
DataValueField="ID" ondatabound="ckblstEffect_DataBound">
/asp:CheckBoxList>
在遨游4兼容模式(IE7)下不起作用,仔細(xì)看樣式中的表達(dá)式,怎么看都覺(jué)得不對(duì)勁。
改成下面的樣式就可以了。
復(fù)制代碼 代碼如下:
style>
.ckblstEffect td
{
min-width:80px;
width:expression(this.offsetWidth 80 ? "80px" : "auto");
}
/style>
在IE10、遨游4極速模式及兼容模式下均可正確顯示最小寬度,此樣式除了用于CheckBoxList外,也可用于DIV等。
如果有發(fā)現(xiàn)其它瀏覽器不能顯示CheckBoxList選項(xiàng)最小寬度的,請(qǐng)通知我。
您可能感興趣的文章:- layui表格checkbox選擇全選樣式及功能的實(shí)例
- jQuery實(shí)現(xiàn)自定義checkbox和radio樣式
- android開(kāi)發(fā)教程之自定義控件checkbox的樣式示例
- CheckBoxList多選樣式j(luò)query、C#獲取選擇項(xiàng)
- 利用JavaScript更改input中radio和checkbox樣式
- 控制input的CSS但不影響CheckBox以及Radio的樣式
- 用圖片替換checkbox原始樣式并實(shí)現(xiàn)同樣的功能