我想知道如何将我的导航栏中的所有链接连续排成一行。这是我的CSS和HTML。感谢
HTML -
<ul class="nav">
<h3 class="navlogo">LOGO HERE</h3>
<li><a href="#Home">Home</a></li>
<li><a href="#About">About</a></li>
<li><a href="#Work">Work</a></li>
<li><a href="#Services">Services</a></li>
<li><a href="#Contact">Contact</a></li>
</ul>
CSS -
.nav {
font-family: Poppins, sans-serif;
font-size: 25px;
font-weight: bold;
padding: 20px 0px 20px 0px;
text-align: center;
margin: 0;
opacity: 0.70;
background-color: #3b3b3b;
white-space: nowrap;
}
.nav li {
display: inline-block;
padding: 0 25px 1px 25px;
font-size: 16px
}
.nav li a {
text-decoration: none;
color: white;
margin: 0;
font-family: sans-serif;
}
.nav li a:hover {
color: #1C86EE;
font-weight: bold;
}
我希望导航栏主要位于我页面的中心。我还在页面中安装了jquery和bootstrap。
答案 0 :(得分:0)
使用Bootstrap v4,我创建了this演示,希望对您有所帮助。
使用Bootstrap在其示例页面上提供的标记:
<nav class="navbar navbar-toggleable-md navbar-inverse bg-inverse fixed-top">
<button class="navbar-toggler navbar-toggler-right" type="button" data-toggle="collapse" data-target="#navbarsExampleDefault" aria-controls="navbarsExampleDefault" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<a class="navbar-brand" href="#">Navbar</a>
<div class="collapse navbar-collapse" id="navbarsExampleDefault">
<ul class="navbar-nav mr-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Link</a>
</li>
<li class="nav-item">
<a class="nav-link disabled" href="#">Disabled</a>
</li>
<li class="nav-item dropdown">
<a class="nav-link dropdown-toggle" href="http://example.com" id="dropdown01" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">Dropdown</a>
<div class="dropdown-menu" aria-labelledby="dropdown01">
<a class="dropdown-item" href="#">Action</a>
<a class="dropdown-item" href="#">Another action</a>
<a class="dropdown-item" href="#">Something else here</a>
</div>
</li>
</ul>
</div>
</nav>
答案 1 :(得分:0)
我建议使用Bootstrap
答案 2 :(得分:0)
使用Bootstrap,你必须在
部分添加它
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">
<!-- Optional theme -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap-theme.min.css" integrity="sha384-rHyoN1iRsVXV4nD0JutlnGaslCJuC7uwjduW9SVrLvRYooPp2bWYgmgJQIXwl/Sp" crossorigin="anonymous">
<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa" crossorigin="anonymous"></script>