我可以使用以下代码创建一个带有水平滚动条的 ASP.NET ListBox
<div style="width:160px; overflow-x:auto;">
<asp:ListBox ID="ListBox1" runat="server"></asp:ListBox>
</div>
但是如何将 min-width
属性设置为 ListBox
以便即使不存在元素也不会缩小。我尝试使用 CSS 的 min-width
,但没有得到它。
我访问了一个页面 here ,但我无法在代码隐藏文件中对其进行格式化。
最佳答案
您可以通过将 min-width
CSS 属性设置为 100%
来实现这一点,如下所示:
<asp:ListBox ID="ListBox1" runat="server" style="min-width:100%;">
希望这对您有所帮助。
关于c# - 具有最小宽度和水平滚动条的 ASP.NET ListBox,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8710527/