2016-11-07 49 views
0

我想使用固定在我頁面頂部的引導程序導航欄。然後我想要有一個div,它覆蓋了頁面的其餘部分。我通過應用類容器流體來解決寬度問題。不過,我已經調整了容器高度爲93.5%,並將html溢出設置爲隱藏。這適用於全屏窗口。但是,此解決方案不會響應並且窗口大小調整失敗。我希望div容器的高度自動填充頁面的其餘部分。代號爲波紋管:Bootstrap - 爲單頁格式導航欄和容器

CSS

html { 
    height:100%; 
    overflow:hidden; 
} 
body { 
    height:100%; 
} 

#map-container{ 
    height:93.5%; 
    border-color: black; 
    border-style:solid; 
    border-width:2px; 
    margin:5px; 

} 
.navbar{ 
    margin-left:5px; 
    margin-right: 5px; 
    margin-top:5px; 
    margin-bottom:0px; 

} 

HTML

<!DOCTYPE html> 

<html> 
<head> 
    <meta name="viewport" content="width=device-width" /> 
    <title>quickMap</title> 

    <!-- Bootstrap Core CSS --> 
    <link href="~/Content/bootstrap.min.css" rel="stylesheet"> 
    <!-- Custom CSS --> 
    <link href="~/Content/quickMap.css" rel="stylesheet" > 

</head> 
<body> 
    <nav class="navbar navbar-default"> 
     <div class="container-fluid"> 
      <!-- Brand and toggle get grouped for better mobile display --> 
      <div class="navbar-header"> 
       <button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#bs-example-navbar-collapse-1" aria-expanded="false"> 
        <span class="sr-only">Toggle navigation</span> 
        <span class="icon-bar"></span> 
        <span class="icon-bar"></span> 
        <span class="icon-bar"></span> 
       </button> 
       <a class="navbar-brand" href="#">Brand</a> 
      </div> 

      <!-- Collect the nav links, forms, and other content for toggling --> 
      <div class="collapse navbar-collapse" id="bs-example-navbar-collapse-1"> 
       <ul class="nav navbar-nav"> 
        <li class="active"><a href="#">Link <span class="sr-only">(current)</span></a></li> 
        <li><a href="#">Link</a></li> 
        <li class="dropdown"> 
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a> 
         <ul class="dropdown-menu"> 
          <li><a href="#">Action</a></li> 
          <li><a href="#">Another action</a></li> 
          <li><a href="#">Something else here</a></li> 
          <li role="separator" class="divider"></li> 
          <li><a href="#">Separated link</a></li> 
          <li role="separator" class="divider"></li> 
          <li><a href="#">One more separated link</a></li> 
         </ul> 
        </li> 
       </ul> 
       <form class="navbar-form navbar-left"> 
        <div class="form-group"> 
         <input type="text" class="form-control" placeholder="Search"> 
        </div> 
        <button type="submit" class="btn btn-default">Submit</button> 
       </form> 
       <ul class="nav navbar-nav navbar-right"> 
        <li><a href="#">Link</a></li> 
        <li class="dropdown"> 
         <a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">Dropdown <span class="caret"></span></a> 
         <ul class="dropdown-menu"> 
          <li><a href="#">Action</a></li> 
          <li><a href="#">Another action</a></li> 
          <li><a href="#">Something else here</a></li> 
          <li role="separator" class="divider"></li> 
          <li><a href="#">Separated link</a></li> 
         </ul> 
        </li> 
       </ul> 
      </div><!-- /.navbar-collapse --> 
     </div><!-- /.container-fluid --> 
    </nav> 
    <div class="container-fluid" id="map-container"> 
     <div> 

     </div> 
    </div> 
    <!-- jQuery --> 
    <script src="~/Scripts/jquery-1.10.2.min.js"></script> 

    <!-- Bootstrap Core JavaScript --> 
    <script src="~/Scripts/bootstrap.min.js"></script> 
</body> 
</html> 

回答

0

我認爲溢出:隱藏是搞亂你。我將其改爲自動,它對我來說足夠好用了。

html { 
height:100%; 
overflow:auto; 
} 

不知道93.5%是高度準確的權數,因爲,至少在我的瀏覽器,在div最終被在窗口稍微有點高,但是這可以通過調整高度來固定稍短。更像91%的東西。