我是Bootstrap世界的新手,只是尝试制作一个简单的卷轴。
<!DOCTYPE html>
<html>
<head>
<title>Team Avero | Home</title>
<link rel="stylesheet" href="css/bootstrap.css">
<link rel="stylesheet" href="css/style.css">
<script src="js/bootstrap.js"></script>
</head>
<body data-spy="scroll" data-target="#navbar">
<div class="container">
<ul class="nav nav-tabs pull-left" id="navbar">
<li class="active"><a href="#jumbotron">Home</a></li>
<li><a href="#news">News</a></li>
<li><a href="#">Team</a></li>
<li><a href="#">Social Media</a></li>
</ul>
<ul class="nav nav-tabs pull-right">
<li><a href="#">Avero Store</a></li>
<li><a href="#">Forums</a></li>
</ul>
</div>
<div class="jumbotron">
<div class="container">
<h1>Team Avero</h1>
<p>provides the best tools, services and more in the modding community. Guaranteed.</p>
</div>
</div>
<div class="news">
<div class="container">
<p>This is a test.</p>
<p>This is a test.</p>
<p>This is a test.</p>
<p>This is a test.</p>
<p>This is a test.</p>
<p>This is a test.</p>
<p>This is a test.</p>
</div>
</div>
</body>
</html>
布局很好,但是当我点击导航中的“新闻”项时,它不会滚动到div类新闻。怎么了?
答案 0 :(得分:3)
您已指定<div class="news">
它应为<div id="news">
,因为您已使用#news
作为锚标记。
#指id和。是指班级
答案 1 :(得分:0)
尝试替换
<ul id="navbar">
...
</ul>
到
<div id="navbar">
<ul>
...
</ul>
</div>