我使用标准的navbar bootstrap 4汉堡菜单进入较小的屏幕作为标准杆,然而,当在较小的屏幕上进行测试时,它包裹在导航栏品牌位置下方,我似乎无法找到css的一部分,以使其与徽标浮动在同一行。它的问题是它在较小的屏幕上遮挡了它下方的标题,这对移动观众来说并不理想。
我使用CDN进行最新的bootstrap 4 Beta
以下是我正在玩的页面的链接:link:
有人能指出我正确的方向吗?非常感谢!
我加入的HTML如下:
HTML:
<nav class="navbar navbar-expand-sm bg-light navbar-light fixed-top">
<div class="container-fluid navbrand">
<a href="index.html" class="navbar-brand"><img src="img/sflogo.png" style="width:80%;height:80%;"/></a>
<button class="navbar-toggler" data-toggle="collapse" data-target="#hamburgerMenu"><span class="navbar-toggler-icon"></span></button>
<div class="collapse navbar-collapse" id="hamburgerMenu" style="opacity:1;">
<ul class="navbar-nav ml-auto">
<li class="nav-item"><a href="#" class="nav-link">Home</a></li>
<li class="nav-item"><a href="#" class="nav-link">About</a></li>
<li class="nav-item"><a href="#" class="nav-link">Services</a></li>
<li class="nav-item"><a href="#" class="nav-link">Contact</a></li>
</ul>
</div>
</div>
</nav>
<header id="home-section">
<img src="img/headbg.jpg" style="width:100%; height:auto;" />
</header>
<div class="underhead">
We have "Goods In Transit" Insurance!<br />
<span style="font-weight:normal;">Rest assured all your items will be covered during your move.</span>
</div>
CSS是:
body {
background-color: #fff;
color: #f2e000;
}
.navbar-light .navbar-brand {
font-weight:bold;
color: #f2e000;
}
.navbar-light .navbar-nav .nav-link {
color: #333;
}
.container .navbar-brand:hover {
color: #000;
}
.navbar {
opacity: 0.8;
}
.nav-link {
font-weight:bolder;
font-size: 20px;
}
.navbar-light .navbar-nav .nav-link:focus, .navbar-light .navbar-nav .nav-link:hover {
color: #f2e000;
}
#home-section {
margin-top:4.5em;
}
.underhead {
background:#f2e000;
color:#333;
text-align:center;
font-weight:bold;
font-size:2vw;
width:100%;
padding:20px;
}
@media (max-width:500px) {
.underhead {
font-size: 0.8em;
}
}
@media (max-width: 460px) {
.navbrand img {
width:40%;
height:40%;
}
}
答案 0 :(得分:1)
您可以通过调整css更改来实现相同的目标:
@media (max-width: 575px) {
button.navbar-toggler {
position: absolute !important;
right: 10px !important;
top: 14px !important;
}
}