简体   繁体   English

Bootstrap导航栏中的文本后跟按钮

[英]Text followed by button in Bootstrap navbar

I would like to have some text, then a button, right aligned in a Bootstrap 3 navbar. 我想要一些文本,然后是一个按钮,在Bootstrap 3导航栏中右对齐。 I can add the corresponding components, but whatever I tried the result is ugly. 我可以添加相应的组件,但是尝试执行的结果都很丑陋。 I never managed to get it right so any help would be appreciated: 我从来没有设法做到正确,所以任何帮助将不胜感激:

<div class="container-fluid">
    <div class="row">  
        <div class="navbar navbar-inverse">
            <div class="navbar-header">
                <a class="navbar-brand" href="#">Brand</a>
            </div>
            <div class="nav pull-right">
                <p class="navbar-text">text in navbar...</p>
                <button class="btn btn-info">then a button</button>
            </div>
        </div>
    </div>
</div>

The text looks ok but the button is stuck in the upper right corner. 文本看起来不错,但是按钮卡在了右上角。

Here is a link to bootply 这是bootply的链接

Try adding the following CSS 尝试添加以下CSS

.navbar .navbar-text{
   float: none;
   display: inline-block;
}

The default display property of .navbar-text is block , which is forcing it to be in a separate line. .navbar-text的默认display属性是block ,这迫使它位于单独的行中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM