1

我无法让徽标在折叠时留在导航栏的右上角。请参阅图像以了解问题。

折叠的内容

折叠前的导航栏

审查代码:

    <nav class="navbar navbar-expand-md fixed-top navbar-light blue-grey lighten-5 mx-auto">
    <div class="container">

    <!-- Collapse Button -->
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#mobileNav" aria-controls="mobileNav" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

    <!-- Collapsible Content -->
    <div class="collapse navbar-collapse justify-content-md-center font-weight-bold" id="mobileNav">

        <!-- Links Left -->
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link" href="#">Internet</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Building Managers</a>
            </li>
        </ul>

        <!-- Navbar Brand -->
        <a id="logo" class="navbar-brand" href="index.html">
            <img class="hidden-sm-down" src="img/logoNav.png" alt="Lone Star Fiber"> 
        </a>

        <!-- Links Right -->
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link" href="#">Business Internet</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Developers</a>
            </li>
        </ul>
    </div>
</nav>
4

2 回答 2

0

用于d-none d-md-block在 sm 屏幕尺寸上隐藏图像并在 sm 尺寸d-md-none d-sm-block上显示不在折叠内的图像。

见小提琴:https ://jsfiddle.net/khz5uv1r/25/

img{
  height:50px;
  width:50px;
}
  <nav class="navbar navbar-expand-md fixed-top navbar-light blue-grey lighten-5 mx-auto">
    <div class="container">

    <!-- Collapse Button -->
    <button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#mobileNav" aria-controls="mobileNav" aria-expanded="false" aria-label="Toggle navigation">
        <span class="navbar-toggler-icon"></span>
    </button>

    <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/css/bootstrap.min.css">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.0/umd/popper.min.js"></script>
  <script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.0/js/bootstrap.min.js"></script>
  <!-- Collapsible Content -->

          <div class="pic d-md-none d-sm-block">
        <a id="logo"  href="index.html">
            <img src="https://material.angular.io/assets/img/examples/shiba1.jpg" alt="Lone Star Fiber"> 
        </a>
        </div>
    <nav class="collapse navbar-collapse justify-content-md-center font-weight-bold" id="mobileNav">
        <ul class="navbar-nav">
            <li class="nav-item">
                <a class="nav-link" href="#">Internet</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Building Managers</a>
            </li>
        <li class="nav-item pic d-none d-md-block">
        <a id="logo"  href="index.html">
            <img src="https://material.angular.io/assets/img/examples/shiba1.jpg" alt="Lone Star Fiber"> 
        </a>
        </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Business Internet</a>
            </li>
            <li class="nav-item">
                <a class="nav-link" href="#">Developers</a>
            </li>
        </ul>
    </div>
    </div>
</nav>

于 2018-06-27T06:20:45.360 回答
0

我认为该方法应该类似于:Bootstrap NavBar with left, center or right alignment items

使用 2nav-collapse与相同的 .mobile-nav 目标分开。使用order-*类在右侧的移动菜单之前显示徽标...

<nav class="navbar navbar-expand-md fixed-top navbar-light blue-grey lighten-5 mx-auto">
    <div class="container">

        <!-- Collapse Button -->
        <button class="navbar-toggler" type="button" data-toggle="collapse" data-target=".mobile-nav" aria-controls="mobileNav" aria-expanded="false" aria-label="Toggle navigation">
            <span class="navbar-toggler-icon"></span>
        </button>

        <!-- Collapsible Content -->
        <div class="collapse navbar-collapse justify-content-md-center font-weight-bold mobile-nav order-2">

            <!-- Links Left -->
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a class="nav-link" href="#">Internet</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">Building Managers</a>
                </li>
            </ul>
            </div>
            <!-- Navbar Brand -->
            <a id="logo" class="navbar-brand order-1 order-md-2 text-center" href="index.html">
                <img class="" src="//placehold.it/130x30?text=Lone Star Fiber" alt="Lone Star Fiber">
            </a>
            <div class="collapse navbar-collapse justify-content-md-center font-weight-bold mobile-nav order-2">

            <!-- Links Right -->
            <ul class="navbar-nav">
                <li class="nav-item">
                    <a class="nav-link" href="#">Business Internet</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="#">Developers</a>
                </li>
            </ul>
        </div>
    </div>
</nav>

https://www.codeply.com/go/iVjzxDF7Gf

于 2018-06-27T15:49:19.463 回答