Html input[type="submit"] - 单击时更改背景
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3310736/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
input[type="submit"] - change background when clicked
提问by stefa.rossi
I have a simple <input type="submit" value="Search">
submit button.
In the CSS i have styled it with input[type="submit"]
and input[type="submit"]:hover
so it changes its background by default and when hovered. Is there a way to change its background when clicked?
我有一个简单的<input type="submit" value="Search">
提交按钮。在 CSS 中,我使用了它的样式input[type="submit"]
,input[type="submit"]:hover
因此默认情况下和悬停时它会更改其背景。有没有办法在单击时更改其背景?
回答by Jani Hartikainen
You should be able to use input[type=submit]:active
, similar to how you'd style links.
您应该能够使用input[type=submit]:active
,类似于您设置链接样式的方式。
Do note that this will not function properly in IE6 (not sure about 7 and 8)
请注意,这在 IE6 中无法正常运行(不确定 7 和 8)
回答by Matty F
input[type="submit"]:active {
color: green;
}