html - CSS 悬停不适用于嵌套类

标签 html css hover

有人可以解释为什么“悬停”对我的 CSS 不起作用吗?我想要将鼠标悬停在播放按钮上以将鼠标光标更改为“指针”的操作。

jsfiddle 在这里:http://jsfiddle.net/2vqsA/5

html:

<link href="//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css" rel="stylesheet">
<body>
    <div class="imageframe">
        <img name="slideImg" src="someImage.jpg" width=500 height=375 border=0></img>
        <div class="animcontrol">
            <table cellpadding='5'>
                <tbody>
                    <tr>
                        <td>
                            <div class="play" onclick="playAnim();"></div>
                        </td>
                    </tr>
                </tbody>
            </table>
        </div>
    </div>

CSS:

.imageframe {
position: relative;
z-index: -1;
max-width: 35em;
max-height: 60em;
padding: 0.5em 0.5em 0.5em 0.5em;
background-color:rgba(255, 255, 255, 0.4);
border: 1px solid rgba(0, 0, 0, 0.4);
border-radius: 10px;
box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.4);
filter:alpha(opacity=40);
/* For IE8 and earlier */
}
.animcontrol {
position: relative;
min-width: 5%;
max-width: 12em;
max-height: 5em;
padding: 0.2em 0.2em 0.2em 0.2em;
background-color: #ffffff;
border: 1px solid rgba(0, 0, 0, 0.4);
border-radius: 10px;
z-index: 100;
}
.play:before {
font-family: FontAwesome;
font-size: 24px;
content:"\f04b";
color: rgba(84, 84, 90, 1);
}
.imageframe:hover .play{
cursor: pointer;
}

感谢任何帮助或建议。

最佳答案

只需从

中删除 z-index:-1
.imageframe {
    position: relative;

    max-width: 35em;
    max-height: 60em;
    padding: 0.5em 0.5em 0.5em 0.5em;
    background-color:rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(0, 0, 0, 0.4);
    border-radius: 10px;
    box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.4);
    filter:alpha(opacity=40);
    /* For IE8 and earlier */
}

并添加这个CSS

.animcontrol:hover{

   cursor: pointer; 

}

Working Demo

关于html - CSS 悬停不适用于嵌套类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21072607/

相关文章:

html - Bootstrap 导航栏下拉列表中的注销表单

CSS 对图像的过渡效果

javascript - jQuery渐变下沉效果按钮

css - 对 div 内的内联图像应用悬停图像效果

html - "Responsive image over responsive image"- 推特 Bootstrap

javascript - 存储十六进制 HTML 颜色作为数值转换返回不同的颜色

html - 适合内容高度的两个div

css - html div float 和调整大小

javascript - 如何使标题闪烁直到它与 jQuery 一起激活?

html - CSS:按下空格键时未选中复选框