CSS 面包屑导航到引导程序 3.0.2 中的导航栏

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20270438/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 01:09:12  来源:igfitidea点击:

Breadcrumb into a navbar in bootstrap 3.0.2

csstwitter-bootstraptwitter-bootstrap-3

提问by Kalamarico

I'm new on Bootstrap, and i want to create a navbar with some stuff (links, dropdown...) and a breadcrumb. But i have a problem with the display: block (i think...) when i put a breadcrumb into a navbar, this is my example code:

我是 Bootstrap 的新手,我想用一些东西(链接、下拉菜单...)和面包屑创建一个导航栏。但是我的显示有问题:block(我认为...)当我将面包屑放入导航栏中时,这是我的示例代码:

<nav class="navbar navbar-inverse navbar-static-top" role="navigation">
      <div class="container">

        <ul class="nav navbar-nav navbar-right">
          <ul class="breadcrumb list-inline">
            <li><a href="#">Home</a></li>
            <li><a href="#">Library</a></li>
            <li class="active">Data</li>
          </ul>
          <li class="dropdown">
            <a href="#" class="dropdown-toggle" data-toggle="dropdown">Hello George <b class="caret"></b></a>
            <ul class="dropdown-menu">
              <li><a href="#">Settings</a></li>
              <li><a href="#">Logout</a></li>
            </ul>
          </li>
          <li>
            <span class="glyphicon glyphicon-info-sign icons-padding"></span>
          </li>
          <li><a href="#">Help</a></li>
          <li>
            <span class="glyphicon glyphicon-off icons-padding"></span>
          </li>
          <li><a href="#">Exit</a></li>
        </ul>
      </div>
    </nav>

http://jsfiddle.net/calamarico/r9yEU/2/embedded/result/

http://jsfiddle.net/calamarico/r9yEU/2/embedded/result/

How can i put inline the breadcrumb and the other stuff in the same line?

如何将面包屑和其他内容内联在同一行中?

回答by zessx

A simple float: leftwill do the work (margins are here to for vertical alignment) :

一个简单的float: left将完成工作(边距用于垂直对齐):

.nav .breadcrumb {
    margin: 0 7px;
}
@media (min-width: 768px) {
    .nav .breadcrumb {
        float: left;
        margin: 7px 10px;
    }
}

enter image description here

在此处输入图片说明

Updated fiddle(I also fixed your icon bug on mobile version)

更新的小提琴(我还修复了您在移动版本上的图标错误)

回答by s.benve

This is my solution, it works with toogle button and collapse div too:

这是我的解决方案,它也适用于工具按钮和折叠 div:

<nav class="navbar navbar-default" role="navigation">
    <div class="navbar-header">
        <button type="button" class="navbar-toggle" data-toggle="collapse" data-target=".navbar-collapse">
            <span class="sr-only">Toggle navigation</span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
            <span class="icon-bar"></span>
        </button>
        <!-- this is my custom breadcrumb -->
        <p class="navbar-text navbar-right">
            <!-- a glyphicon as homepage -->
            <a class="navbar-link" href="#" title="homepage"><span class="glyphicon glyphicon-home icons-padding"></span></a>
            &nbsp;>&nbsp;&nbsp;
            <a class="navbar-link" href="#">Link1</a>                  
            &nbsp;>&nbsp;&nbsp;
            <a class="navbar-link" href="#">Link2</a>                  
            &nbsp;>&nbsp;&nbsp;
            <a class="navbar-link" href="#">Link3</a>                  
            &nbsp;>&nbsp;&nbsp;
            Link4
        </p>
        <!-- end -->
    </div>
    <div class="collapse navbar-collapse">
        <ul class="nav navbar-nav navbar-right">
            <li><a href="#">
                    <span class="glyphicon glyphicon-off icons-padding">
                    </span>
                    Exit
                </a>
            </li>
        </ul>
    </div>
</nav>

You need to edit css just to modify the link appeal:

您只需要编辑 css 即可修改链接请求:

a.navbar-link {
    text-decoration: underline;
}

It works with btn too: just add, to link class, "btn btn-default btn-xs".

它也适用于 btn:只需添加链接类,“btn btn-default btn-xs”。