2017-08-28 129 views
0

我一直试图通过使用float将bootstrap4中的导航栏移动到屏幕的右侧:right;在导航上,它只是没有做任何事情。我正在使用codepen应用程序为我正在执行的项目编写代码。在引导中将导航栏移动到右侧

HTML代码:

<div class="container-fluid"> 
<class="row"> 
<header> 
<nav class="navbar navbar-fixed-top"> 
<a href="#" class="glyphicon glyphicon-user">About</a> 
<a href="#" class="glyphicon glyphicon-th-large">Portfolio</a> 
<a href="#" class="glyphicon glyphicon-envelope">Contact</a> 
</div> 
</nav> 
</header> 
</div> 
</div> 
</body> 
</html> 

CSS文件:

@import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css'); 

nav a { 
    color: black; 
    padding: 10px; 
    font-size: 32px; 
    background-color: gray; 
} 
+0

有什么问题吗? –

+0

你能提供codepen吗? –

回答

0

其做工精细,只需添加浮动:权重;在你的CSS

@import url('//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css'); 

nav a { 
    color: black; 
    padding: 10px; 
    font-size: 32px; 
    background-color: gray; 
    float: right !important; 
} 

这里是笔:Working Example (CodePen)

+0

你会碰巧知道为什么当我将链接浮动到引导程序的右边时,列表会改变顺序吗?它不会在常规的CSS中这样做。 –

+0

你可能会错过某些东西,或者你的css class/id没有正确地继承或者你的代码中有一些其他的含糊不清,如果你把你的代码同时发布到HTML和CSS上,会有很多问题。 @JamesVelardi –