CSS :hover function not working

标签 css

我正在尝试向我使用 CSS 完成的网页添加图像。问题是我创建了一个显示图像右侧的悬停功能。这确实有效,但是当我添加 position: relative 或 z-index: -1 时,悬停功能不起作用。有什么办法可以解决这个问题而不用去掉 position 或 z-

谢谢

http://jsfiddle.net/L5rvkt2g/

#logo {
        background: url(http://upload.wikimedia.org/wikipedia/commons/b/b9/1875_CC_double_eagle.jpg);
        width: 956px;
        height: 884px;
        background-position: left;
        margin: auto;
        position: relative;
        z-index: -1;
    }

        #logo:hover {
            background-position: right;
        }

最佳答案

问题是关于 z-index: -1; 因为鼠标不能悬停索引低于 0,所以悬停不起作用。删除它,它会很好地工作!

关于CSS :hover function not working,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26020507/

相关文章:

javascript - html 不显示插入的 javascript 代码

html - 如何对齐 flexbox 中的元素?

javascript - 在 body 负荷上向下滑动一个 div

html - 在 iframe 中隐藏来自外部源的内容顶部?

html - CSS 多重叠加导致高度为零

php - 为选择元素设置占位符

jquery - 使用没有插件的 css3 和 jquery 滑入和滑出

html - 全屏谷歌地图背景 div 与 CSS

css - 你会如何定位这些图像?

css - 当用户缩放时变形的 div