我的 CSS 中有以下内容:
.myclasss:hover {
background: url("images/arw_flogin2.png") no-repeat; border: none;
display: block;
width: 90px;
height: 50px;
}
以及我的 HTML 中的以下内容:
<input type="image" title="" class="myclasss" src="images/arw_flogin1.jpg" />
如果我更改输入类型以提交它有效,但在作为图像时无效。
最佳答案
您需要在非悬停状态下使用背景图片。使用以下 css 以及输入 type="submit"
CSS
.myclasss {
background: url("images/arw_flogin1.png") no-repeat; border: none;
display: block;
width: 90px;
height: 50px;
}
.myclasss:hover {
background: url("images/arw_flogin2.png") no-repeat; border: none;
}
HTML
<input type="submit" class="myclasss" value="" />
当您使用图像类型的输入时,您在 src
属性中设置的图像将应用于前景。因此,当您在悬停时更改背景时,您将看不到它,因为 src
图像仍在前景中。
关于CSS 无法识别悬停状态,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14159375/