2017-09-04 58 views
1

我正在嘗試在我的項目中添加overlay,以保護用戶在內容完全下載之前不會進行大量互動。這就是爲什麼我添加了覆蓋如下:爲什麼我的覆蓋層無法覆蓋自舉激活欄?

.overlay { 
    opacity: 0.5; 
    background: #000; 
    width: 100%; 
    height: 100%; 
    z-index: 10; 
    top: 0; 
    left: 0; 
    position: fixed; 
} 

但問題是,覆蓋可以覆蓋所有整個頁面的100%,除此以外引導的導航欄。請幫助我如何覆蓋自舉導航欄上的覆蓋圖。

<div class="overlayIndex"></div> 
<div class="navbar navbar-default navbar-static-top navbar-fixed-top"> 
    <div class="container"> 
    <div class="row">.......</div> 
    </div> 
</div> 
<div ng-view="" autoscroll="true"></div> 

enter image description here

+2

設置你的'Z-index'到1031,看看有沒有做的伎倆? – cwanjt

+1

這樣設置'z-index'多於'navbar':'z-index:9999' –

+0

@cwanjt你可以發表答案嗎? – ppshein

回答

1

設置你的z-index到1031引導的navbar-fixed-top使用的1030的z-index設置上面這應該讓您的疊加覆蓋整個視口。

引導的CSS的navbar-fixed-top類:

.navbar-fixed-top { 
    position: fixed; 
    right: 0; 
    left: 0; 
    z-index: 1030; 
} 
1

試試這個...!

<!DOCTYPE html> 
 
<html lang="en"> 
 
<head> 
 
    <title>Bootstrap Example</title> 
 
    <meta charset="utf-8"> 
 
    <meta name="viewport" content="width=device-width, initial-scale=1"> 
 
    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
 
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script> 
 
    <script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 
 
    <style> 
 
.overlay { 
 
    opacity: 0.5; 
 
    background: #000; 
 
    width: 100%; 
 
    height: 100%; 
 
    z-index: 10; 
 
    top: 0; 
 
    left: 0; 
 
    position: fixed; 
 
} 
 
    </style> 
 
</head> 
 
<body> 
 
<div class="overlay"></div> 
 
<nav class="navbar navbar-default" style="margin-bottom:0px;"> 
 
    <div class="container-fluid"> 
 
    <div class="navbar-header"> 
 
     <button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar"> 
 
     <span class="icon-bar"></span> 
 
     <span class="icon-bar"></span> 
 
     <span class="icon-bar"></span>       
 
     </button> 
 
     <a class="navbar-brand" href="#">Logo</a> 
 
    </div> 
 
    <div class="collapse navbar-collapse" id="myNavbar"> 
 
     <ul class="nav navbar-nav"> 
 
     <li class="active"><a href="#">Home</a></li> 
 
     <li><a href="#">About</a></li> 
 
     <li><a href="#">Projects</a></li> 
 
     <li><a href="#">Contact</a></li> 
 
     </ul> 
 
     <ul class="nav navbar-nav navbar-right"> 
 
     <li><a href="#"><span class="glyphicon glyphicon-log-in"></span> Login</a></li> 
 
     </ul> 
 
    </div> 
 
    </div> 
 
</nav> 
 

 
<div id="myCarousel" class="carousel slide" data-ride="carousel"> 
 
    <!-- Indicators --> 
 
    <ol class="carousel-indicators"> 
 
     <li data-target="#myCarousel" data-slide-to="0" class="active"></li> 
 
     <li data-target="#myCarousel" data-slide-to="1"></li> 
 
    </ol> 
 

 
    <!-- Wrapper for slides --> 
 
    <div class="carousel-inner" role="listbox"> 
 
     <div class="item active"> 
 
     <img src="https://placehold.it/1200x400?text=IMAGE" alt="Image"> 
 
     <div class="carousel-caption"> 
 
      <h3>Sell $</h3> 
 
      <p>Money Money.</p> 
 
     </div>  
 
     </div> 
 

 
     <div class="item"> 
 
     <img src="https://placehold.it/1200x400?text=Another Image Maybe" alt="Image"> 
 
     <div class="carousel-caption"> 
 
      <h3>More Sell $</h3> 
 
      <p>Lorem ipsum...</p> 
 
     </div>  
 
     </div> 
 
    </div> 
 

 
    <!-- Left and right controls --> 
 
    <a class="left carousel-control" href="#myCarousel" role="button" data-slide="prev"> 
 
     <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span> 
 
     <span class="sr-only">Previous</span> 
 
    </a> 
 
    <a class="right carousel-control" href="#myCarousel" role="button" data-slide="next"> 
 
     <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span> 
 
     <span class="sr-only">Next</span> 
 
    </a> 
 
</div> 
 
<footer class="container-fluid text-center"> 
 
    <p>Footer Text</p> 
 
</footer> 
 
</body> 
 
</html>