在完整的窗口屏幕上,我完全按照我的想法準備了導航欄。但是,一旦我將窗口設置得很小以檢查它是否反應良好,我不會獲取所有菜單按鈕(家,技能,關於,聯繫人)一個接着一個,其次當我調整窗口屏幕回到全屏時,導航欄變小。bootstrap導航欄響應不工作
<!DOCTYPE html>
<html lang="en">
<head>
<!-- Required meta tags always come first -->
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/css/bootstrap.min.css" integrity="sha384-y3tfxAZXuh4HwSYylfB+J125MxIs6mR5FOHamPBG064zB+AFeWH94NdvaCBm8qnd" crossorigin="anonymous">
<style type="text/css">
#navbar .nav-pills .nav-item.open .nav-link,
#navbar .nav-pills .nav-item.open .nav-link:focus,
#navbar .nav-pills .nav-item.open .nav-link:hover,
#navbar .nav-pills .nav-link.active,
#navbar .nav-pills .nav-link.active:focus,
#navbar .nav-pills .nav-link.active:hover
{
background-color: #e7e7e7;
border-color: transparent;
color: #555555;
}
.navbar-default
{
background-color: #610B0B ;
border-radius:0px;
}
.navbar.center .navbar-inner
{
text-align: center;
}
.navbar.center .navbar-inner .nav
{
float: none;
display:inline-block;
}
.navbar-default .navbar-nav > li > a
{
color: white;
font-size: 15px;
font-family: 'Droid Serif', Georgia, Times, serif;
letter-spacing: 1px;
margin: 3px 10px -3px 10px;
border: 2px solid transparent;
padding: 8px;
}
.navbar-default .navbar-nav > li > a:hover,
.navbar-default .navbar-nav > li > a:focus
{
border: 2px solid white;
border-radius: 5px;
color: white;
padding: 8px;
}
.navbar-default .navbar-nav > .active > a,
.navbar-default .navbar-nav > .active > a:hover,
.navbar-default .navbar-nav > .active > a:focus
{
border: 2px solid white;
border-radius: 5px;
color: #555;
background-color: #E7E7E7;
}
.navbar-default .navbar-nav > .open > a,
.navbar-default .navbar-nav > .open > a:hover,
.navbar-default .navbar-nav > .open > a:focus
{
color: #555;
background-color: #D5D5D5;
}
</style>
</head>
<body data-spy="scroll" data-target="#navbar">
<div id="navbar">
<nav class="navbar navbar-default center navbar-fixed-top" id="navbar">
<button class="navbar-toggler hidden-sm-up" type="button" data-toggle="collapse" data-target="#exCollapsingNavbar2">☰</button>
<div class="collapse navbar-toggleable-xs" id="exCollapsingNavbar2">
<a class="navbar-brand" href="#"></a>
<div class="navbar-inner">
<ul class="nav navbar-nav nav-pills">
<li class="nav-item">
<a class="nav-link active" href="#jumbotron">HOME <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#about">ABOUT</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#skills">SKILLS</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#contact">CONTACT</a>
</li>
</ul>
</div>
</div>
</nav>
</div>
</body>
<!-- jQuery first, then Bootstrap JS. -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.4/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.2/js/bootstrap.min.js" integrity="sha384-vZ2WRJMwsjRMW/8U7i6PWi6AlO1L79snBrmgiDpgIWJ82z8eA5lenwvxbMV1PAh7" crossorigin="anonymous"></script>
</body>
</html>
只是好奇,如果你有包括bootstrap.js文件。 –
是的,包括所有引導程序導入。 –
確保你包含jquery。 –