当前,当屏幕尺寸低于特定点时,我的徽标和移动下拉菜单无法保持在同一行。我尝试使用媒体查询来缩小图像,但仍然遇到相同的问题。我在这里阅读了另一篇文章,使用css设置导航栏品牌背景,而不是将其嵌入img标签,但是当我尝试不显示图像时。
这是我的html
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../../../favicon.ico">
<title>Pristine Clean Outs | Home</title>
<!-- Bootstrap core CSS -->
<link rel="stylesheet" href="css/bootstrap.min.css">
<!-- Carousel style-->
<link href="css/carousel.css" rel="stylesheet">
<!--Custom Styles-->
<link rel="stylesheet" href="css/style.css">
</head>
<body id="top">
<header>
<div class="container-fluid">
<nav class="navbar navbar-expand-md navbar-light fixed-top bg-white">
<a class="navbar-brand" href="index.html"><img class="img-fluid logo" src="img/pristinelogo.png" alt=""></a>
<button class="navbar-toggler" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarCollapse">
<ul class="navbar-nav ml-auto">
<li class="nav-item active">
<a class="nav-link" href="index.html">Home <span class="sr-only">(current)</span></a>
</li>
<li class="nav-item">
<a class="nav-link" href="about.html">About</a>
</li>
<li class="nav-item">
<a class="nav-link" href="gallery.html">Gallery</a>
</li>
<li class="nav-item">
<a class="nav-link" href="contact.html">Contact</a>
</li>
</ul>
</div>
</nav>
</div>
</header>
这是我的CSS
/* Custom Styles for Pristine Clean by David Jacoby */
nav li {
font-size: 22px;
}
.carousel-item {
text-shadow: 2px 2px #000000;
}
.port-image {
width: 100%;
}
.gallery_product {
margin-bottom: 30px;
}
.contact-ul li {
font-size: 24px;
list-style-type: none;
}
/* MEDIA QUERIES */
@media (max-width: 768px) {
.logo {
width: 70%;
height: auto;
}
}
答案 0 :(得分:1)
将品牌和切换器包裹在另一个flexbox div(d-flex
)中,并使用flex-nowrap
来防止包裹...
<div class="d-flex flex-nowrap w-100">
<a class="navbar-brand" href="index.html"><img class="img-fluid logo" src="https://s22.postimg.cc/tf57x6fq9/pristinelogo.png" alt=""></a>
<button class="navbar-toggler ml-auto" type="button" data-toggle="collapse" data-target="#navbarCollapse" aria-controls="navbarCollapse" aria-expanded="false" aria-label="Toggle navigation">
<span class="navbar-toggler-icon"></span>
</button>
</div>