select:disabled {
background-color: #BBBBBB;
}
<select disabled>
<option>test</option>
</select>
如果您在 Chrome 上运行上面的代码,然后使用颜色选择器检查选择标记的背景颜色,您将得到 #CFCFCF
而不是 #BBBBBB
在标签上执行相同的操作可以按预期工作,这是 chrome 中的错误还是我遗漏了某些内容?
最佳答案
disabled
更改元素的不透明度。添加不透明度:1;
select:disabled {
background: #BBBBBB;
opacity: 1;
}
<select disabled>
<option>test</option>
</select>
关于html - 禁用的选择标签没有在 chrome 上的 css 中指定的颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74822861/