如何将<li>元素放在汉堡图标下面?

时间:2017-01-01 05:45:23

标签: css twitter-bootstrap css3 bootstrap-4 twitter-bootstrap-4

如何在移动模式下将列表元素'Home'放在Bootstrap 4中的汉堡图标和徽标下?我尝试将Logo显示为style =“display:block”但不起作用。

<div class="container">
  <nav class="navbar navbar-light bg-faded">
    <button class="navbar-toggler hidden-sm-up float-xs-left" type="button" 
    data-toggle="collapse" data-target="#navbar-header"     
    aria-controls="navbar-header" 
    aria-expanded="false" aria-label="Toggle navigation"></button>
    <a class="navbar-brand hidden-md-up" href="/">Logo</a>
    <div class="collapse navbar-toggleable-xs" id="navbar-header">
      <ul class="nav navbar-nav">
        <a class="navbar-brand hidden-sm-down" href="/">Logo</a>
        <li class="nav-item {% block navhome %}{% endblock %}">
          <a class="nav-link float-left" href="/">Home <span 
           class="sr-only">(current)</span></a>
        </li>

1 个答案:

答案 0 :(得分:0)

如果你想让它垂直堆叠(就像在3.x中那样),你必须为Bootstrap 4添加一些额外的CSS。

@media(max-width:576px) {
    .navbar .navbar-nav>.nav-item {
        float: none;
        margin-left: .1rem;
    }
    .navbar .navbar-nav {
        float:none !important;
    }
    .navbar .collapse.in, .navbar .collapsing  {
        clear:both;
    }
}

http://www.codeply.com/go/JyrJRy93P7

另外,在this anwser中解释。