无法使居中徽标在折叠时重新定位到右侧
Cannot get centered logo to reposition to the right on collapse
我无法让徽标在折叠时保留在导航栏的右上角。查看问题图片。
Collapsed content
Navbar before collapse
审核代码:
<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>
使用 d-none d-md-block
在 sm 屏幕尺寸上隐藏图像,在 sm 尺寸上使用 d-md-none d-sm-block
显示不在折叠内的图像。
参见fiddle: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>
我认为方法应该类似于:Bootstrap NavBar with left, center or right aligned items
对相同的 .mobile-nav 目标使用 2 个单独的 nav-collapse
。使用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>
我无法让徽标在折叠时保留在导航栏的右上角。查看问题图片。
Collapsed content
Navbar before collapse
审核代码:
<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>
使用 d-none d-md-block
在 sm 屏幕尺寸上隐藏图像,在 sm 尺寸上使用 d-md-none d-sm-block
显示不在折叠内的图像。
参见fiddle: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>
我认为方法应该类似于:Bootstrap NavBar with left, center or right aligned items
对相同的 .mobile-nav 目标使用 2 个单独的 nav-collapse
。使用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>