html - 如何更改下拉列表中禁用的选项文本颜色?

标签 html css

如何更改 select 菜单中禁用的 option 的字体颜色? (不是选择本身,只是它在下拉菜单中的选项) 我想这样做是因为在 chrome/safari 中,禁用/启用选项之间几乎没有区别(见第一张图片)。在 IE 中,差异在某种程度上是显而易见的。在 Firefox 中很明显。

以下方法仅适用于 FF。我怎样才能以跨浏览器的方式做到这一点? https://jsfiddle.net/6wazms1a/3/

HTML:

<select>
    <!-- I want to change text color of 'disabled' in the pull down list. 
Reason: Make non-disabled options more prominent (like in IE and Firefox) -->
    <option disabled>disabled</option> 
    <option selected>enabled selected</option>
    <option>other enabled</option>   
    <option>another enabled</option>
</select>

CSS:

option:disabled,
option[disabled],
option[disabled="disabled"] { color: #ccc; }

到目前为止我的结果:

Chrome/浏览器

不好。启用/禁用选项之间几乎没有区别。我几乎分不清哪些已启用哪些未启用。

Firefox 和 IE(确定)

很好。很容易发现禁用的选项

最佳答案

看看这是否有效: -webkit-text-fill-color:blue;

来源: Disabled input text color

关于html - 如何更改下拉列表中禁用的选项文本颜色?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33464541/

相关文章:

html - 向 Bootstrap 添加 header

javascript - 当我选择一个选项值时,如何让 Javascript 知道?

html - 溢出?随着容器尺寸变大,元素被推出

css transform :rotate, 向前旋转而不是向后旋转

javascript - 附加到 $ ("a"的 jquery 效果)选择器不起作用

html - 指向 svg 元素的 CSS .target 属性

css - 永久修改不属于我的网站的 CSS,并将更改分发到我的网络

html - Angular Material 2 : How to put a fab button on top of the md-table at the bottom right corner?

html - 仅在一定深度内显示元素,直至展开

html - 将双指缩放 div 图像添加到移动设备上的不可缩放视口(viewport)