在 CSS 中设置图像按钮 - image:active
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12543697/
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
Setting an image button in CSS - image:active
提问by user1666411
I'm trying to replace the submit button with an image by defining it in a class="myButton"
and change the styles in CSS. the myButton:active
doesn't seem to work when being clicked.
我试图通过在 a 中定义它class="myButton"
并更改 CSS 中的样式来用图像替换提交按钮。在myButton:active
似乎没有工作被点击时。
Here is my CSS:
这是我的 CSS:
.myButton{
background:url(./images/but.png) no-repeat;
cursor:pointer;
border:none;
width:100px;
height:100px;
}
myButton:active {
background:url(./images/but2.png) no-repeat;
}
HTML code:
HTML代码:
<input class="myButton" type="submit" value="">
回答by Mr_Green
Check this link. You were missing .
before myButton
. It was a small error. :)
检查此链接。你失踪.
之前myButton
。这是一个小错误。:)
.myButton{
background:url(./images/but.png) no-repeat;
cursor:pointer;
border:none;
width:100px;
height:100px;
}
.myButton:active /* use Dot here */
{
background:url(./images/but2.png) no-repeat;
}