我是webApps的新手,我正在尝试使用Bootstrap构建一个投资组合页面。 问题是如果我在可折叠导航中使用nav-bar-nav类,我的网页看起来似乎很敏感。
但如果我使用Bootstrap nav-bar-nav更改nav-pills,我将无法看到可折叠的菜单按钮。请参阅下面的图片以供参考: -
我从W3School学习了可折叠菜单,我试图合并stackoverflow post。
你可以在Code Pan Here中看到我迄今为止所尝试的内容: - http://codepen.io/hiteshsahu/pen/PNBarB
我的HTML
<nav class="navbar nav-right">
<div class="container-fluid">
<div class="navbar-header">
<button type="button" class="navbar-toggle" data-toggle="collapse" data-target="#myNavbar">
<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="#">WebSiteName <span class="glyphicon glyphicon-log-in"></span></a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav nav-pills head-menu" style ="float:right">
<li><a href="#">Contact</a></li>
<li><a href="#">Portfolio</a></li>
<li><a class="active" href="#">About</a></li>
</ul>
</div>
</div>
</nav>
CSS
.nav {
background-color :#722872;
height: 60px;
display: flex;
justify-content: center;
align-items: center;
}
.navbar {
background-color :#722872;
}
请帮我指出我做错了什么,我以前没有网络用户界面的经验。
答案 0 :(得分:0)
好的,
<!DOCTYPE html>
<html lang="en">
<head>
<title>Bootstrap Case</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.0/jquery.min.js"></script>
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<style>
body {
background-color: linen;
}
.nav {
background-color :#722872;
height: 60px;
display: flex;
justify-content: center;
align-items: center;
}
.navbar {
background-color :#722872;
}
</style>
</head>
<body>
<nav class="navbar navbar-inverse">
<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="#">WebSiteName</a>
</div>
<div class="collapse navbar-collapse" id="myNavbar">
<ul class="nav nav-pills navbar-right">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Page 2</a></li>
<li><a href="#">Page 3</a></li>
</ul>
</div>
</div>
</nav>
<div class="container">
<h3>Collapsible Navbar</h3>
<p>In this example, the navigation bar is hidden on small screens and replaced by a button in the top right corner (try to re-size this window).
<p>Only when the button is clicked, the navigation bar will be displayed.</p>
</div>
</body>
</html>
Updated Code pan以防任何人想要这样做。