0
嗨,大家好我是通過個人網頁學習bootstrap的。我已經創建了一個帶有附加選項的導航欄,但是向右滾動時,右邊界似乎已經斷開。你能幫我弄清楚爲什麼?提前 謝謝,下面的代碼:在導航欄上的bootstrap'affix'打破右邊距
<!DOCTYPE html>
<html lang="en">
<head>
<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.1.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>
<style>
.affix {
top: 0;
width: 100%;
}
.affix + .container-fluid {
padding-top: 70px;
}
</style>
</head>
<body>
<div class="container-fluid">
<div class="alert alert-warning alert-dismissable fade in">
<a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
<strong>Warning!</strong> This site uses cookies
</div>
<nav class="navbar navbar-inverse" data-spy="affix" data-offset-top="197">
<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="#">Something</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav navbar-nav">
<li><a href="#">Home</a>
</li>
<li><a href="#">Pag 1</a>
</li>
<li><a href="#">Pag 2</a>
</li>
</ul>
<ul class="nav navbar-nav navbar-right">
<li>
<a href="#"> <span class="glyphicon glyphicon-log-in"> </span>
</a>
</li>
</ul>
</div>
</div>
</div>
<div class="container-fluid" style="height:1000px">
<h1>Some text to enable scrolling</h1>
<h1>Some text to enable scrolling</h1>
<h1>Some text to enable scrolling</h1>
<h1>Some text to enable scrolling</h1>
<h1>Some text to enable scrolling</h1>
<h1>Some text to enable scrolling</h1>
<h1>Some text to enable scrolling</h1>
<h1>Some text to enable scrolling</h1>
<h1>Some text to enable scrolling</h1>
<h1>Some text to enable scrolling</h1>
<h1>Some text to enable scrolling</h1>
</div>
</body>
</html>
編輯:使用Chrome檢查我找到了一個警告。它說:「關鍵」寬度:設備寬度「不被識別和忽略。」
謝謝你的快速回復!這適用於我,但我試圖找到一種方法來省略navbar聲明中的「navbar-fixed-top」類,因爲我不太喜歡它的外觀。 – Pasq
我還注意到,navbar-fixed-top導航覆蓋了我的示例文本,所以它不是我正在搜索的解決方案。 – Pasq