【问题标题】:Bootstrap 4 branding element pushing navbar to a new lineBootstrap 4 品牌元素将导航栏推向新的路线
【发布时间】:2017-08-23 09:02:40
【问题描述】:

I want to have a fixed top navbar like this with (Because its one list item I dont need the hamburger toggleable feature)

但是,导航栏品牌元素将导航推到了新行。我尝试了 pull-right 类和 justify-content-end,但其中一个有效。

It looks like this.

到目前为止,我的代码是这样的。感谢您的帮助!

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>

【问题讨论】:

标签: css navigation navbar nav


【解决方案1】:

使用类 'navbar-header' 将您的品牌包装到 div 并使用:

float:left

float:right

到.navbar-nav

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-12-10
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-27
    • 2017-09-15
    • 1970-01-01
    • 2021-01-29
    相关资源
    最近更新 更多