Bootstrap 4动画导航栏不显示
Posted
技术标签:
【中文标题】Bootstrap 4动画导航栏不显示【英文标题】:Bootstrap 4 Animated Navbar Not Displaying 【发布时间】:2019-02-25 09:55:48 【问题描述】:我试图实现图标栏变成 X 的动画导航栏。我记得在 Bootstrap 3 中这样做很好,但在 4 中它似乎不起作用,甚至没有显示折叠的菜单图标栏在页面上?
<!-- Navigation -->
<nav class="navbar navbar-expand-lg navbar-dark bg-dark fixed-top">
<div class="container">
<a class="navbar-brand" href="#">Start Bootstrap</a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarResponsive" aria-controls="navbarResponsive" aria-expanded="false" aria-label="Toggle navigation">
<span class="icon-bar top-bar"></span>
<span class="icon-bar middle-bar"></span>
<span class="icon-bar bottom-bar"></span>
<span class="sr-only">Toggle navigation</span>
</button>
<div class="collapse navbar-collapse" id="navbarResponsive">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="#">Home
<span class="sr-only">(current)</span>
</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Services</a>
</li>
<li class="nav-item">
<a class="nav-link" href="#">Contact</a>
</li>
</ul>
</div>
CSS
.navbar-toggler
border: none;
background: transparent !important;
.navbar-toggler:focus
outline: none;
background: transparent !important;
.navbar-toggler .icon-bar
background-color: #fff;
transform: rotate(0deg) translate(0px, 0px);
transition: ease all .2s;
.navbar-toggler .icon-bar
display: block;
width: 22px;
height: 2px;
border-radius: 1px;
.navbar-toggler .icon-bar+.icon-bar
margin-top: 4px;
.icon-bar:nth-child(2)
width: 16px;
transition: ease all .2s;
.navbar-toggler:hover>.icon-bar:nth-child(2)
width: 22px;
transition: ease all .2s;
.navbar-toggler:active>.icon-bar:nth-child(2)
width: 22px;
transition: ease all .2s;
.navbar-toggler:not(.collapsed) .icon-bar:nth-child(1)
transform: rotate(45deg) translate(5px, 4px);
transition: ease all .2s;
.navbar-toggler:not(.collapsed) .icon-bar:nth-child(2)
opacity: 0;
transition: ease all .2s;
.navbar-toggler:not(.collapsed) .icon-bar:nth-child(3)
transform: rotate(-45deg) translate(4px, -4px);
transition: ease all .2s;
【问题讨论】:
嗨,你能把你的代码使用工作snippet
为什么这被标记为 twitter-bootstrap-3??
【参考方案1】:
您的 Given 代码运行良好。我认为您的CSS由于某种原因没有申请。 请检查以下链接。
[https://jsfiddle.net/Kunshtech/q41fcnzs/][1]
【讨论】:
以上是关于Bootstrap 4动画导航栏不显示的主要内容,如果未能解决你的问题,请参考以下文章
Bootstrap 4 导航栏不会在 Angular 4 中折叠