更改 HTML 下拉选项字体大小
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/24761965/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Change HTML dropdown option font size
提问by Michael Samuel
I have this simple HTML dropdown menu:
我有这个简单的 HTML 下拉菜单:
<select>
<option style="font-size:50px;">Test</option>
</select>
I can't find a way to increase the font size of the option. The font-size property is being ignored for some reason. Is this a bug or what?
我找不到增加选项字体大小的方法。由于某种原因, font-size 属性被忽略。这是错误还是什么?
Thanks
谢谢
采纳答案by Krupal Shah
回答by underbar
Have you tried putting it on your <select>
element?
你试过把它放在你的<select>
元素上吗?
<select style="font-size:50px;">
<option>Test</option>
</select>
fiddle: http://jsfiddle.net/tCw8M/
小提琴:http: //jsfiddle.net/tCw8M/
Or with a stylesheet:
或者使用样式表:
select {
font-size: 50px;
}
fiddle: http://jsfiddle.net/tCw8M/2/
回答by David Morin
The font size option needs to be on the select tag, not the option tag:
字体大小选项需要在选择标签上,而不是选项标签上:
<select style="font-size:50px;">
<option >Test</option>
</select>
Whether you do it directly to the tag or in a css file selecting the tag is up to you.
是直接对标签进行操作还是在 css 文件中选择标签取决于您。
回答by Alex Char
回答by rob
Put it in a stylesheet:
把它放在一个样式表中:
select{
font-size: 150px;
}
check out the example : http://jsfiddle.net/robcabrera/bx8R4/