我正在为一家电影公司的网站制作一个主页,它有一个带有悬停效果的 CSS 按钮,一旦准备好就会打开一个灯箱,目前我只是将其设置为 href="#" 作为一个占位符,直到我准备好实现灯箱。还有一个向下箭头的小图像,链接设置为尚未出现在页面上的锚点。这两个元素都可以在 Firefox 中使用,但在 Chrome 中,悬停效果在按钮上不起作用,并且其行为就像这些元素周围都没有锚标记一样。我用 Chrome 的开发工具摸索了一下,似乎按钮周围的跨度可能是罪魁祸首,因为 Chrome 似乎正在调整它的大小,但我无法找出图像链接不起作用的任何原因,而且我'我不完全确定为什么 Chrome 不同意跨度。
奇怪的是,在一个单独的 div 中还有另外三个具有悬停效果的 CSS 按钮,而且它们都工作得很好。
该网站目前上传于http://www.gruntwork.us/reelindi/test/ http://www.gruntwork.us/reelindi/test/样式表可以在以下位置找到http://www.gruntwork.us/reelindi/test/reelindi.css http://www.gruntwork.us/reelindi/test/reelindi.css
CSS:
div.header {
position:absolute;
top: 0;
left: 0;
right: 0;
background-image:url("resources/images/bg.jpg");
background-size:cover;
-webkit-background-size: cover;
-moz-background-size: cover;
-o-background-size: cover;
height:430px;
width:100%;
z-index: -1;
}
img.arrow {
display: block;
margin-left: auto;
margin-right: auto;
margin-top: 58px;
z-index: 999;
}
span.redBtn a {
text-align:center;
display:block;
margin: 0 auto;
width: 150px;
margin-top: -40px;
z-index: 999;
}
a.redBtn {
color: #fff;
background-color: #d94d4d;
font-size: 1.125em;
padding: 8px 18px;
text-decoration: none;
text-align: center;
-webkit-transition: all ease 1s;
-moz-transition: all ease 1s;
-o-transition: all ease 1s;
-ms-transition: all ease 1s;
transition: all ease 1s;
border-radius: 5px;
}
a.redBtn:hover {
background-color: #bf3030;
}
HTML:
<div class="header">
<h1 class="header">Reel Indi</h1>
<h2 class="header">"Storytelling in motion."</h2><br>
<span class="redBtn"><a href="#" class="redBtn">Push the red button!</a></span>
<a href="#footer"><img class="arrow" src="resources/images/arrow.png"></a>
</div>
我四处搜寻但找不到这个问题的答案。帮助?
看起来像你的header
's z-index: -1
规则将所有内容推到正文内容“后面”,导致您无法接收该层上的鼠标事件。将其更改为零或更高将使您能够获得悬停效果和其他事件。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)