[英]Style select box drop-down menu like a table
I am using a select box in my codes which contains 50 options, by default when I click on it, drop down menu appears like below: 我在代码中使用了一个选择框,其中包含50个选项,默认情况下,当我单击它时,下拉菜单如下所示:
<select name="Select1" style="width: 56px"> <option></option> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </select>
but I want it to appears like a table: 但我希望它看起来像一张桌子:
I tried some CSS and JS but didn't work, is there any way to do this? 我尝试了一些CSS和JS,但是没有用,有什么办法可以做到这一点?
With just a <select>
element, no . 仅使用
<select>
元素,否。 . 。 .
。 HTML select boxes are some of the most limited, when it comes to cross-browser support for styling.
当涉及样式的跨浏览器支持时,HTML选择框是最受限制的。 Even the most "flexible" browser are extremely restrictive on what they let you change ( some font styling, some color support, sizing and spacing is about the most you should expect to get).
即使是最“灵活”的浏览器也对它们允许您更改的内容有严格的限制( 某些字体样式, 某些颜色支持,大小和间距是您应该期望获得的最大内容)。
If you have to have a table-like structure, you are limited to using libraries or building a custom interface that mimic a dropdown (usually using styled divs and some flavor of "show/hide" or "slide" animation). 如果必须具有类似表的结构,则只能使用库或构建模仿下拉菜单的自定义界面(通常使用样式化的div和“显示/隐藏”或“幻灯片”动画的某种风格)。 Here is another similar SO thread that has MANY suggestions to choose from: Is it possible to style a select box?
这是另一个类似的SO线程,有很多建议可供选择: 是否可以设置选择框的样式?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.