Bootstrap 4折叠导航栏

时间:2016-10-17 06:09:20

标签: html css twitter-bootstrap navbar bootstrap-4

我正在尝试重新安排我使用Bootstrap 4制作的折叠导航栏。它现在看起来像这样:

enter image description here

有没有办法将社交媒体按钮对齐在一条线上,然后带上'关于'进一步向下并摆脱“项目”前面的空间。和'联系'?

到目前为止我的代码:

<nav class="navbar navbar-fixed-top navbar-light bg-faded">
<button class="navbar-toggler hidden-sm-up" type="button" data-toggle="collapse" data-target="#exCollapsingNavbar2" aria-controls="exCollapsingNavbar2" aria-expanded="false" aria-label="Toggle navigation">
    &#9776;
</button>
<div class="collapse navbar-toggleable-xs" id="exCollapsingNavbar2">
    <a class="navbar-brand" href="#">Timo Springer</a>
    <ul class="nav navbar-nav m-x-auto" style="width: 300px;">
        <li class="nav-item">
            <a class="nav-link" href="#about">About</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="#projects">Projects</a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="#contact">Contact</a>
        </li>
    </ul>
    <ul class="nav navbar-nav pull-md-right">
        <li class="nav-item">
            <a class="nav-link" href="https://www.facebook.com/timo.springer"><i class="fa fa-facebook" aria-hidden="true"></i></a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="https://www.instagram.com/springertimo/?hl=en"><i class="fa fa-instagram" aria-hidden="true"></i></a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="https://500px.com/timospringer"><i class="fa fa-500px" aria-hidden="true"></i></a>
        </li>
        <li class="nav-item">
            <a class="nav-link" href="https://de.linkedin.com/in/timo-springer-372468129"><i class="fa fa-linkedin" aria-hidden="true"></i></a>
        </li>

    </ul>
</div>

非常感谢!

蒂莫

2 个答案:

答案 0 :(得分:0)

只需在媒体广告管理系统的导航标记中添加clear:both

即可
@media (max-width:767px){
  .nav.m-x-auto{
    clear:both;
    margin: 0 !important;
  }
  .nav.navbar-nav.pull-md-right li{
    float:left;   
  }
   .nav.navbar-nav.pull-md-right li + li{
      margin-left: 1rem;
   }
}

这是Demo

答案 1 :(得分:0)

我认为以下内容应该有效。

ul.nav.navbar-nav.m-x-auto {
float: none!important;
clear: both!important;
width: 100%!important;
}

ul.nav.navbar-nav.pull-md-right {
width: 100%!important;
clear: both!important;
float: none!important;
}

ul.nav.navbar-nav.pull-md-right > li {
width: 25%;
text-align: center;
display: inline-block!important;
}