html - 禁用的选择标签没有在 chrome 上的 css 中指定的颜色

标签 html css google-chrome

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/

相关文章:

css - -webkit-transform : translate3d(); trigger hardware acceleration for the whole page, 还是仅针对目标元素?

html - GitLab 默认 url 不安全

javascript - 悬停在 MouseEnter 和 onMouseLeave React 上不起作用。超出最大调用堆栈大小

html - 可变/缩放宽度图像 : 5x20% greater than 100%?

html - 当我缩小 web 4 div 到下一行

javascript - 在哪里放置我的 chrome 扩展的主要代码?

html - 如何删除表格行或 "column"中两个按钮之间的空格?

html - 在两个并排的无序列表中排列列表元素

javascript - 自动折叠网格主题中帖子之间的垂直间距

javascript - 请求在 chrome 中偶尔会停滞很长时间