nav navbar-nav navbar-right不会向右对齐,我使用Bootstrap 3

时间:2017-06-22 17:26:04

标签: twitter-bootstrap alignment navbar nav

我创建的导航栏包含左侧对齐的徽标和右侧的菜单,这里是我的代码(html和css):如何将3个链接对齐到右边?我明白这个类:nav navbar-nav navbar-right应该这样做但不会,谢谢!



h1 {
	text-align: center;
}

.img-thumbnail {
	border: 0 none;
}
.navbar-custom {
    color: #FFFFFF;
    background-color: transparent;
    border-color: transparent;
}

.navbar-toggle {
	background-color: #000000; 
}

.collapse .navbar-collapse {
	float: right;
}

<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1">
		<link rel="stylesheet" type="text/css" href="css/bootstrap.min.css">
		<link rel="stylesheet" href="css/style.css">
		<title> Randomoooooooood</title>
	</head>
	<body>
			
		<header class="navbar navbar-inverse navbar-custom">
			 <div class="container-fluid">
					 <div class="row">
						 <div class="col-md-4">
								 <div class="header-left clearfix">
									 <div class="logo smooth-scroll">

									        <a href="#banner"> <img id="logo" src="img/randomood_log.png" class="col-xs-4 col-sm-4 col-md-4 col-lg-2∫ img-thumbnail" alt="Randomood"></a>
									        
									        
									 </div>
									    <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>

									    </div>
									    <div class="collapse navbar-collapse" id="myNavbar">

														
																
														
										 
									     
									      <ul class="nav navbar-nav navbar-right">
									        <li><a href="#">Page 1</a></li>
									        <li><a href="#">Page 2</a></li> 
									        <li><a href="#">Page 3</a></li> 
									      </ul>

										</div>	      

						</div>	      
					</div>
			</div>
		</header>
				
			
	<script src="js/jquery-1.11.3.min.js"></script>
    <script src="js/bootstrap.min.js"></script>		
	</body>	
</html>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

.navbar-collapse.col-md-4的兄弟,后者强制您的标题仅使用总可用空间的1/3。