当前位置: 移动技术网 > IT编程>开发语言>.net > asp.net CheckBoxList 各项最小宽度CSS样式

asp.net CheckBoxList 各项最小宽度CSS样式

2018年03月18日  | 移动技术网IT编程  | 我要评论

中山安全教育平台,绿人,哥特王朝4卡顿

ASP.NET中,CheckBoxList里的选择都是自动宽度的,属性时没有设置各项宽度的设置。

 

参考了一下网上的最小宽度样式,

[html] 

/* 最小寬度 */    

.min_width{min-width:300px;    

  /* sets max-width for IE */    

  _width:expression(document.body.clientWidth < 300 ? "300px" : "auto");    

}   

 

写成如下:

[html]  

<style>  

.ckblstEffect td  

{  

    min-width:80px;  

    _width:expression(document.body.clientWidth < 80 ? "80px" : "auto");        

}  

</style>  

[html] view plaincopy

<asp:CheckBoxList ID="ckblstEffect" runat="server" DataTextField="MC"   

                            RepeatDirection="Horizontal" RepeatColumns="10" CssClass="ckblstEffect"  

                            DataValueField="ID" ondatabound="ckblstEffect_DataBound">  

                        </asp:CheckBoxList>  

在遨游4兼容模式(IE7)下不起作用,仔细看样式中的表达式,怎么看都觉得不对劲。

 

改成下面的样式就可以了。

[html]  

<style>  

.ckblstEffect td  

{  

    min-width:80px;  

    width:expression(this.offsetWidth < 80 ? "80px" : "auto");        

}  

</style>  

 

在IE10、遨游4极速模式及兼容模式下均可正确显示最小宽度,此样式除了用于CheckBoxList外,也可用于DIV等。

如果有发现其它浏览器不能显示CheckBoxList选项最小宽度的,请通知我。

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网