【发布时间】:2025-12-29 16:30:12
【问题描述】:
我已经建立了this fiddle 作为我正在做的一个例子。
我正在尝试做的事情在 Firefox 中运行良好。当您打开选择选项时,字体大小为 14px。
但是在 Google Chrome 中查看它会选择继承的 34px 字体大小。
理想情况下,我希望选择字体大小为 14px。
这可能吗?
如果需要,我愿意在 jQuery 中进行任何相关的修复。
谢谢
代码如下......
.styled-select {
overflow: hidden;
height: 74px;
float: left;
width: 365px;
margin-right: 10px;
background: url(http://i50.tinypic.com/9ldb8j.png) no-repeat right center #5c5c5c;
}
.styled-select select {
font-size: 34px;
border-radius: 0;
border: none;
background: transparent;
width: 380px;
overflow: hidden;
padding-top: 15px;
height: 70px;
text-indent: 10px;
color: #ffffff;
-webkit-appearance: none;
}
.styled-select option.service-small {
font-size: 14px;
padding: 5px;
background: #5c5c5c;
}
<div class="styled-select">
<select class="service-area" name="service-area">
<option selected="selected" class="service-small">Service area?</option>
<option class="service-small">Volunteering</option>
<option class="service-small">Partnership & Support</option>
<option class="service-small">Business Services</option>
</select>
</div>
【问题讨论】:
-
我知道这是一个古老的问答(~2013 年),但我想分享一个很棒的解决方案,我刚刚发现它确实适用于所有(大多数)浏览器:Pure CSS select dropdown style – override the default select dropdown styles with CSS 9 月 22 日发布, 2015 by Jeff Hays @ robido.com 我首先发现了这个 * Q&A,所以想与以后可能会遇到这个问题的其他人分享我的发现。
-
您在问题中说这适用于 Firefox,但我认为它不再适用于 Firefox。