CSS 无法识别悬停状态

标签 css image button hover submit

我的 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/

相关文章:

html - 当窗口调整大小时更改 div 大小以进行缩放

python-3.x - jupyter notebook 中图像的交互式标注

PHP while循环制作图像表

python - 按钮回调怎么写?

javascript - 无法按字母顺序自动对按钮进行排序

css - 自举网格偏移

jquery - 在 Div 中获取文本并找到匹配的 HTML 并添加类

android - 无法在opencv中加载haarcascadeshaarcascade.xml

c# - 如何创建一个在统一中充当按钮的模型?

javascript - 根据页眉和页脚高度改变高度的动态内容