我的导航栏在桌面和移动分辨率方面都非常出色。我唯一的问题是,一旦网站缩小到移动尺寸,导航栏最小化为一个图标(这绝对是好的)并从左到右而不是从上到下展开(这就是问题所在)。它看起来很难看,我无法找到解决方案。
<nav class="navbar navbar-expand-lg navbar-light bg-light">
<a href="index.html"><img src="images/finfab-logo.jpg" alt="Company logo"></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarSupportedContent" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarSupportedContent">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link text-white" href="index.html">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active">
<a class="nav-link text-white" href="about.html">About<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active">
<a class="nav-link text-white" href="contact.html">Contact<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active">
<a class="nav-link text-white" href="testimonials.html">Testimonials<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active">
<a class="nav-link text-white" href="recent.html">Recent Work<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active">
<a class="nav-link text-white" href="industrial.html">Industrial<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active">
<a class="nav-link text-white" href="domestic.html">Domestic<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active">
<a class="nav-link text-white" href="steel.html">Steel<span class="sr-only">(current)</span></a>
</li>
<li class="nav-item active">
<a class="nav-link text-white" href="extensions.html">Extensions<span class="sr-only">(current)</span></a>
</li>
</ul>
</div>
</nav>
没有关于此的风格,因为我没有想法。
.navbar .navbar-nav > li > a:hover, .navbar-default .navbar-nav > li > a:focus {
background-color: #006600;
border-radius: 10px;
}
.navbar{
display: flex;
}
.navbar-toggler{
flex:1;
}
.navbar-collapse{
flex:3;
}
.navbar-nav{
border:1px solid;
border-radius: 10px;
border-color: #003300;
background-color: #003300;
}
.nav-item{
font-size: 25px;
font-weight: lighter;
}
.nav-link{
color:#003300;
}
&#13;
答案 0 :(得分:1)
只需移除您添加的自定义flex
CSS,导航栏就会从上到下显示。保留CSS的样式,颜色,边框等。
.navbar .navbar-nav > li > a:hover, .navbar-default .navbar-nav > li > a:focus {
background-color: #006600;
border-radius: 10px;
}
.navbar-nav{
border:1px solid;
border-radius: 10px;
border-color: #003300;
background-color: #003300;
}
.nav-item{
font-size: 25px;
font-weight: lighter;
}
.nav-link{
color:#003300;
}