Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
949 views
in Technique[技术] by (71.8m points)

css - Align a bootstrap navbar to the right

I'm trying to move my navbar to the right, tried both navbar-right, and pull-right, but all I get is something like this -

enter image description here

<div class="container" >
<h1 align="center"><a href="#">My Site</a></h1>
<div class="container" >
<ul class="nav nav-tabs navbar-right" >
  <li class="active"><a href="#">tab1</a></li>
  <li><a href="#">tab2</a></li>
  <li><a href="#">tab3</a></li>
  <li><a href="#">tab4</a></li>  
 </ul>
</div>
<br>
Hello

</div>

So there are 2 problems here - The grey line underneath the tabs is much shorter, and the tabs themselves aren't aligned properly - I want "tab1" to be the rightmost one, and correspondingly "tab4" the leftmost one.

I get the same results for navbar-right and pull-right. How can this be fixed?

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

you can easily have that behavior by just extending the Bootstrap.

enter image description here

Demo on JSBin: http://jsbin.com/zaniz/1/edit?html,css,output

all I did was added a right-to-left class to the <ul> and the CSS Style should be:

.right-to-left li { float: right; }

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...