如何隐藏列表框的垂直滚动条 [英] how to hide the vertical scroll bar of listbox
本文介绍了如何隐藏列表框的垂直滚动条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
< asp:ListBox ID = lboxCategory runat = server AutoPostBack = True align = left
< span class =code-attribute> onselectedindexchanged = lboxCategory_SelectedIndexChanged BackColor = #33CCFF
< span class =code-attribute> 高度 = 100% 宽度 = 100% >
< / asp:ListBox >
解决方案
您好,
您可以指定行的属性值(HTML大小),与列表中的实际选项元素(HTML select_control.length)的数量相同(ASP.NET Iterms.Count)。你也可以用Javascript来做。以下代码段显示了如何使用JavaScript在客户端完成。
< !DOCTYPE html >
< html >
< script >
window .onload = function (){
var lst = document .getElementById(' mylist');
lst.size = lst.length;
alert(lst.length);
}
< / 脚本 >
< 正文 >
< 表格 >
< 选择 id = mylist >
< ; 选项 value < span class =code-keyword> = volvo > Volvo < / option >
< 选项 值 = saab > Saab < / option >
< 选项 value = opel > 欧宝< / option >
< 选项 value = audi > 奥迪< / option >
< 选项 value = 法拉利 > 法拉利< / option >
< span class =code-keyword>< 选项 value = swift > Swift < / option >
< 选项 value = etios > Etios < / option >
< / select >
< / form >
< / body >
< / html >
问候
参考这个类似的主题
http://stackoverflow.com/questions/468980/asp-net-how-to-hide-listbox-control-vertical-scrollbar [<一个href =http://stackoverflow.com/questions/468980/asp-net-how-to-hide-listbox-control-vertical-scrollbartarget =_ blanktitle =新窗口> ^ ]
以下小css技巧希望你能做到这一点
< style type = text / css >
.css-lb {
宽度:100px;
溢出:隐藏;
颜色:灰色;
}
.css-lb select {
border:none;
身高:500px;
}
.css-lb选项{
宽度:100px;
}
< / style >
< div class = css-lb >
< asp:listbox id = ListBox1 runat = server >
< asp:lis titem text = text1 / >
< asp:listitem text = text2 / >
< asp:listitem text = text1 / >
< asp:listitem text = text2 / >
< asp:listitem text = text1 / >
< asp:listitem text = < span class =code-keyword> text2 / >
< asp:listitem text = text1 / >
< asp:listitem text = text2 / >
< asp:listit em text = text1 / >
< asp:listitem text = text2 / >
< / asp:listbox >
< / div >
为我工作希望它能帮到你
<asp:ListBox ID="lboxCategory" runat="server" AutoPostBack="True" align="left" onselectedindexchanged="lboxCategory_SelectedIndexChanged" BackColor="#33CCFF" Height="100%" Width="100%"> </asp:ListBox>解决方案Hello,
You can specify the value for rows attribute (HTML size) same as the number of actual option elements (HTML select_control.length) in the list (ASP.NET Iterms.Count). You can also do it in Javascript. Following snippet shows how it can be done on client side using JavaScript.
<!DOCTYPE html> <html> <script> window.onload = function() { var lst = document.getElementById('mylist'); lst.size = lst.length; alert(lst.length); } </script> <body> <form> <select id="mylist"> <option value="volvo">Volvo</option> <option value="saab">Saab</option> <option value="opel">Opel</option> <option value="audi">Audi</option> <option value="ferrari">Ferrari</option> <option value="swift">Swift</option> <option value="etios">Etios</option> </select> </form> </body> </html>
Regards
Refer this similar thread
http://stackoverflow.com/questions/468980/asp-net-how-to-hide-listbox-control-vertical-scrollbar[^]
with below small css trick hope u can do that
<style type="text/css"> .css-lb { width:100px; overflow:hidden; color:gray; } .css-lb select { border:none; height:500px; } .css-lb option { width:100px; } </style><div class="css-lb"> <asp:listbox id="ListBox1" runat="server"> <asp:listitem text="text1" /> <asp:listitem text="text2" /> <asp:listitem text="text1" /> <asp:listitem text="text2" /> <asp:listitem text="text1" /> <asp:listitem text="text2" /> <asp:listitem text="text1" /> <asp:listitem text="text2" /> <asp:listitem text="text1" /> <asp:listitem text="text2" /> </asp:listbox> </div>
worked for me hope it will help u out
这篇关于如何隐藏列表框的垂直滚动条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文