When I position the element above an image Hover effect stop working. Any idea why? Im learning.
I have some positioned elements, an overlay with opacity on top of a div with a background image in fixed position.
Code entire section and entire CSS :
HTML:
<div class="wrapper"> <!-- Global Wrapper -->
<section>
<div class="first-row">
<div class="first-row__overlay">
</div>
<div class="jumbotron">
<h2 class="jumbotron__header">This is the Title</h2>
<p class="jumbotron__text">Lorem text
</p>
<div class="under-line"></div>
</div>
<a href="#" class="my-Btn">START NOW</a>
</div>
</section>
CSS:
* {
margin: 0;
padding: 0;
font-family: 'Arsenal', sans-serif;
}
.wrapper {
margin: 0;
padding: 0;
}
.first-row {
width: 100%;
height: 100vh;
background: url("../images/paradise-1.jpg") no-repeat fixed center center;
background-size: cover;
text-align: center;
position: relative;
top: 0;
left: 0;
z-index: -100;
}
.first-row__overlay {
background-color: rgba(33, 46, 63, 1);
width: 100%;
height: 100vh;
opacity: .35;
position: relative;
top: 0;
left: 0;
z-index: -99;
}
.jumbotron {
width: 50%;
margin: auto;
color: white;
position: relative;
top: -70vh;
z-index: 1;
background-color: rgba(0, 0, 0, 0.3);
}
.under-line {
height: 10px;
width: 0;
margin: auto;
background-color: transparent;
border-bottom: 1px solid white;
transition: 7s ease;
}
.my-Btn {
position: relative;
top: -67vh;
z-index: 99999999;
color: #1d1e1f;
font-weight: 300;
font-size: 1.2em;
padding: 10px 60px;
background-color: #fdfdfe;
border-radius: 30px;
}
.my-Btn:hover {
cursor: pointer;
}
答案 0 :(得分:0)
您将z-index设置为负位置z-index: -100
,将其从.first-row
类中删除,它将解决该问题。您需要密切关注z-indexing,始终将元素视为一个彼此重叠的堆栈。
.first-row {
width: 100%;
height: 100vh;
background: url("../images/paradise-1.jpg") no-repeat fixed center center;
background-size: cover;
text-align: center;
position: relative;
top: 0;
left: 0;
}