【问题标题】:Disabled property does not change the color in Google Chrome已禁用属性不会更改 Google Chrome 中的颜色
【发布时间】:2014-11-07 00:30:33
【问题描述】:
我有一个带有 css 类的 html 按钮。
<button id="btnPrev" onclick="Prev()" type="button" style="WIDTH: 129px" class="buttons" disabled="">Previous</button>
在 IE 中,如果我设置为禁用,它会将按钮文本颜色从黑色更改为灰色。但在 chrome 中它工作正常,但现在确实改变了按钮文本的颜色。
有什么帮助吗?
【问题讨论】:
标签:
javascript
html
css
google-chrome
internet-explorer
【解决方案1】:
您应该能够通过执行以下操作来设置禁用按钮的外观
button:disabled {
/* Your CSS */
}
除了disabled="",你还需要disabled="disabled"
【解决方案2】:
如果该特定按钮被禁用,您可以添加以下 CSS 以将文本设置为灰色:
#btnPrev:disabled {
color:gray;
}
【解决方案3】:
检查这个小提琴:禁用颜色更改时
fiddle
<button id="btnPrev" onclick="Prev()" type="button" style="WIDTH: 129px;" class="buttons" disabled>Previous</button>
css:
#btnPrev:disabled {
color:yellow;
}