我在.7的覆盖层中的不透明度在轮播中效果很好,但是当我更改浏览器时。
该叠加层位于我的主要内容(H1- btn)等的顶部。我给主要内容一个z-index 3,然后叠加一个z-index 2,但是当我使用firefox时,当我突然进入chrome时效果很好主要内容位于叠加层下,悬停将无法工作。现在什么是解决此问题的最佳解决方案,并使我的主要内容位于叠加层顶部
/********************************/
/* Fade Bs-carousel */
/********************************/
.fade-carousel {
position: relative;
height: 100vh;
}
.fade-carousel .carousel-inner .item {
height: 100vh;
}
.fade-carousel .carousel-indicators > li {
margin: 0 2px;
background-color: #f39c12;
border-color: #f39c12;
opacity: .7;
}
.fade-carousel .carousel-indicators > li.active {
width: 10px;
height: 10px;
opacity: 1;
}
/********************************/
/* main-content Headers */
/********************************/
.main-content {
position: absolute;
top: 60%;
left: 50%;
z-index: 3;
color: #fff;
text-align: center;
text-transform: uppercase;
text-shadow: 1px 1px 0 rgba(0,0,0,.75);
-webkit-transform: translate3d(-50%,-50%,0);
-moz-transform: translate3d(-50%,-50%,0);
-ms-transform: translate3d(-50%,-50%,0);
-o-transform: translate3d(-50%,-50%,0);
transform: translate3d(-50%,-50%,0);
}
.main-content h1 {
color: #fed136;
font-size: 6em;
font-weight: bold;
margin: 0;
padding: 0;
z-index: 3;
}
.fade-carousel .carousel-inner .item .main-content {
opacity: 0;
-webkit-transition: 2s all ease-in-out .1s;
-moz-transition: 2s all ease-in-out .1s;
-ms-transition: 2s all ease-in-out .1s;
-o-transition: 2s all ease-in-out .1s;
transition: 2s all ease-in-out .1s;
}
.fade-carousel .carousel-inner .item.active .main-content {
opacity: 1;
-webkit-transition: 2s all ease-in-out .1s;
-moz-transition: 2s all ease-in-out .1s;
-ms-transition: 2s all ease-in-out .1s;
-o-transition: 2s all ease-in-out .1s;
transition: 2s all ease-in-out .1s;
}
/********************************/
/* Overlay */
/********************************/
.overlay {
-moz-background-size: cover;
-o-background-size: cover;
-webkit-background-size: cover;
background-position: 50% 50%;
position: absolute;
width: 100%;
height: 100%;
z-index: 2;
background-color: #080d15;
opacity: .7;
}
/********************************/
/* Custom Buttons */
/********************************/
.btn.btn-lg {padding: 10px 40px;}
.btn.btn-primary {
color: #f5f5f5;
background-color: #fed136;
border-color: #fed136;
outline: none;
margin: 20px auto;
}
.btn.btn-main-content:hover,
.btn.btn-main-content:focus {
color: #fed136;
background-color: transparent;
border-color: #fed136;
z-index: 3;
}
/********************************/
/* Slides backgrounds */
/********************************/
.fade-carousel .slides .slide-1,
.fade-carousel .slides .slide-2,
.fade-carousel .slides .slide-3 {
height: 100vh;
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
}
.fade-carousel .slides .slide-1 {
background-image: url(../img/bg-taxi03.jpg);
}
.fade-carousel .slides .slide-2 {
background-image: url(../img/bg-taxi04.jpg);
}
.fade-carousel .slides .slide-3 {
background-image: url(../img/bg-taxi02.jpg);
}
/********************************/
/* Media Queries */
/********************************/
@media screen and (min-width: 980px){
.main-content { width: 980px; }
}
@media screen and (max-width: 640px){
.main-content h1 { font-size: 4em; }
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<div class="carousel fade-carousel slide" data-ride="carousel" data-interval="4000" id="bs-carousel">
<!-- Overlay -->
<div class="overlay"></div>
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#bs-carousel" data-slide-to="0" class="active"></li>
<li data-target="#bs-carousel" data-slide-to="1"></li>
<li data-target="#bs-carousel" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item slides active">
<div class="slide-1"></div>
<div class="main-content">
<h1>TAXI EXPRESS</h1>
<h3>A reliable way to travel</h3>
<button class="btn btn-primary btn-lg">Call US Now</button>
</div>
</div>
<div class="item slides">
<div class="slide-2"></div>
<div class="main-content">
<h1>EXPERIENCED</h1>
<h3>Drivers On Your Sercie</h3>
<button class="btn btn-primary btn-lg">Check Our Chauffers</button>
</div>
</div>
<div class="item slides">
<div class="slide-3"></div>
<div class="main-content">
<h1>Services</h1>
<h3>24 / 7 Taxi Service To Any Where Around The City</h3>
<button class="btn btn-primary btn-lg">See Our Services</button>
</div>
</div>
</div>
</div>
最佳答案
/********************************/
/* Fade Bs-carousel */
/********************************/
.fade-carousel {
position: relative;
height: 100vh;
}
.fade-carousel .carousel-inner .item {
height: 100vh;
}
.fade-carousel .carousel-indicators > li {
margin: 0 2px;
background-color: #f39c12;
border-color: #f39c12;
opacity: .7;
}
.fade-carousel .carousel-indicators > li.active {
width: 10px;
height: 10px;
opacity: 1;
}
/********************************/
/* main-content Headers */
/********************************/
.main-content {
position: absolute;
top: 60%;
left: 50%;
z-index: 3;
color: #fff;
text-align: center;
text-transform: uppercase;
text-shadow: 1px 1px 0 rgba(0,0,0,.75);
-webkit-transform: translate3d(-50%,-50%,0);
-moz-transform: translate3d(-50%,-50%,0);
-ms-transform: translate3d(-50%,-50%,0);
-o-transform: translate3d(-50%,-50%,0);
transform: translate3d(-50%,-50%,0);
}
.main-content h1 {
color: #fed136;
font-size: 6em;
font-weight: bold;
margin: 0;
padding: 0;
z-index: 3;
}
.fade-carousel .carousel-inner .item .main-content {
opacity: 0;
-webkit-transition: 2s all ease-in-out .1s;
-moz-transition: 2s all ease-in-out .1s;
-ms-transition: 2s all ease-in-out .1s;
-o-transition: 2s all ease-in-out .1s;
transition: 2s all ease-in-out .1s;
}
.fade-carousel .carousel-inner .item.active .main-content {
opacity: 1;
-webkit-transition: 2s all ease-in-out .1s;
-moz-transition: 2s all ease-in-out .1s;
-ms-transition: 2s all ease-in-out .1s;
-o-transition: 2s all ease-in-out .1s;
transition: 2s all ease-in-out .1s;
}
/********************************/
/* Overlay */
/********************************/
.overlay {
-moz-background-size: cover;
-o-background-size: cover;
-webkit-background-size: cover;
background-position: 50% 50%;
position: absolute;
width: 100%;
height: 100%;
z-index: 2;
background-color: #080d15;
opacity: .7;
}
/********************************/
/* Custom Buttons */
/********************************/
.btn.btn-lg {padding: 10px 40px;}
.btn.btn-primary {
color: #f5f5f5;
background-color: #fed136;
border-color: #fed136;
outline: none;
margin: 20px auto;
}
.btn.btn-main-content:hover,
.btn.btn-main-content:focus {
color: #fed136;
background-color: transparent;
border-color: #fed136;
z-index: 3;
}
/********************************/
/* Slides backgrounds */
/********************************/
.fade-carousel .slides .slide-1,
.fade-carousel .slides .slide-2,
.fade-carousel .slides .slide-3 {
height: 100vh;
background-size: cover;
background-position: center center;
background-repeat: no-repeat;
}
.fade-carousel .slides .slide-1 {
background-image: url(../img/bg-taxi03.jpg);
}
.fade-carousel .slides .slide-2 {
background-image: url(../img/bg-taxi04.jpg);
}
.fade-carousel .slides .slide-3 {
background-image: url(../img/bg-taxi02.jpg);
}
/********************************/
/* Media Queries */
/********************************/
@media screen and (min-width: 980px){
.main-content { width: 980px; }
}
@media screen and (max-width: 640px){
.main-content h1 { font-size: 4em; }
}
.carousel-inner{
z-index:3;
}
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>
<div class="carousel fade-carousel slide" data-ride="carousel" data-interval="4000" id="bs-carousel">
<!-- Overlay -->
<div class="overlay"></div>
<!-- Indicators -->
<ol class="carousel-indicators">
<li data-target="#bs-carousel" data-slide-to="0" class="active"></li>
<li data-target="#bs-carousel" data-slide-to="1"></li>
<li data-target="#bs-carousel" data-slide-to="2"></li>
</ol>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<div class="item slides active">
<div class="slide-1"></div>
<div class="main-content">
<h1>TAXI EXPRESS</h1>
<h3>A reliable way to travel</h3>
<button class="btn btn-primary btn-lg">Call US Now</button>
</div>
</div>
<div class="item slides">
<div class="slide-2"></div>
<div class="main-content">
<h1>EXPERIENCED</h1>
<h3>Drivers On Your Sercie</h3>
<button class="btn btn-primary btn-lg">Check Our Chauffers</button>
</div>
</div>
<div class="item slides">
<div class="slide-3"></div>
<div class="main-content">
<h1>Services</h1>
<h3>24 / 7 Taxi Service To Any Where Around The City</h3>
<button class="btn btn-primary btn-lg">See Our Services</button>
</div>
</div>
</div>
</div>
.carousel-inner{
z-index:3;
}
这是你想要的 ?
关于html - 叠加层隐藏按钮的主要文字和按钮,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/41225567/