我想点击按钮,我也希望将按钮设为图像。这是我的代码。
<input class="refresh" type="button" onClick="clickclick();">
并且css代码是..
.refresh {
background: transparent url(click.png) no-repeat;
width: 30px;
height: 30px;
border: 0px;
cursor: pointer;
}
好处是按钮可以点击但图像没有显示。有任何想法吗?我试图让CSS更容易,但如果有另一种选择,如果成功,我可以尝试一下。感谢
答案 0 :(得分:2)
no-repeat
是background-repeat
值。 background-image
期望仅一个图像标识符,因此您的语法错误并被丢弃。
此外,您仍然使用background:transparent
覆盖它。
尝试:
background: transparent url(click.png) no-repeat;
OR:
background-color: transparent;
background-image: url(click.png);
background-repeat: no-repeat;
答案 1 :(得分:1)
问题是background:transparent;
将其更改为background-color:transparent;
,您的图片就会显示正常。
编辑 - @ niet的答案更完整,使用他的。