我想有一个像这样的固定顶部导航栏(因为它的一个列表项我不需要汉堡可切换功能(
但是,导航栏品牌元素将导航推送到新行。我尝试了右拉类和合理的内容结束,但它们中没有一个起作用。
它看起来像这样。
到目前为止,我的代码是这样的。感谢您的帮助!
body{
padding-top: 130px;
}
.navbar{
padding-top: 1rem;
padding-bottom: 2rem;
height: 130px;
}
.bg-faded{
background-color: white;
}
.navbar-brand{
font-family: 'Lato', sans-serif;
font-size: 2.20rem;
color: rgba(0, 0, 0, 1);
font-weight: 900;
}
.nav-item a{
font-family: 'Lato', sans-serif;
font-size: 0.8rem;
color: rgba(0, 0, 0, 1);
font-weight: 900;
text-transform: uppercase;
}
.jumbotron{
margin-bottom: 0;
}
#week1{
background-image: url('../img/week1.jpg');
background-repeat: no-repeat;
background-position: center;
background-size:100%;
}
<!DOCTYPE html>
<html lang="en">
<head>
<title>52 Weeks of Portrait</title>
<!-- Required meta tags -->
<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.6/css/bootstrap.min.css" integrity="sha384-rwoIResjU2yc3z8GV/NPeZWAv56rSmLldC3R/AZzGRnGxQQKnKkoFVhFQhNUwEyJ" crossorigin="anonymous">
<link rel="stylesheet" href="css/my.css">
<link href="https://fonts.googleapis.com/css?family=Lato:400,700,900|Merriweather" rel="stylesheet">
</head>
<body>
<!-- Navigation Bar -->
<nav class="navbar fixed-top navbar-light bg-faded">
<a class="navbar-brand" href="index.html">52 Weeks of Portrait</a>
<ul class="nav navbar-nav justify-content-end">
<li class="nav-item">
<a class="nav-link" href="#">About + Rules</a>
</li>
</ul>
</nav>
<div class="jumbotron jumbotron-fluid" id="week1">
<div class="container">
<h1 class="display-3">Week One</h1>
<p class="lead"></p>
</div>
</div>
<!-- jQuery first, then Tether, then Bootstrap JS. -->
<script src="https://code.jquery.com/jquery-3.1.1.slim.min.js" integrity="sha384-A7FZj7v+d/sdmMqp/nOQwliLvUsJfDHW+k9Omg/a/EheAdgtzNs3hpfag6Ed950n" crossorigin="anonymous"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/tether/1.4.0/js/tether.min.js" integrity="sha384-DztdAPBWPRXSA/3eYEEUWrWCy7G5KFbe8fFjk5JAIxUYHKkDx6Qin1DkWx51bBrb" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-alpha.6/js/bootstrap.min.js" integrity="sha384-vBWWzlZJ8ea9aCX4pEW3rVHjgjt7zpkNpZk+02D9phzyeVkE+jo0ieGizqPLForn" crossorigin="anonymous"></script>
</body>
</html>
将您的品牌包装成带有类"导航栏标题"的div,并使用:
float:left
和
float:right
到 .navbar-nav