我一直在尝试创建对基本尺寸具有响应性的导航栏,但是我不确定如何将导航链接更改为菜单按钮,可以将其展开以显示导航选项。
我目前拥有的选项只是堆栈并且居中于769px以下,但是我想要的是更多的this nav bar。
这是我目前拥有的:
header {
background-color: #666;
padding: 30px;
text-align: center;
font-size: 35px;
color: white;
}
body {
font-family: 'Montserrat', sans-serif;
line-height: 1.6;
margin: 0;
min-height: 100vh;
}
ul {
margin: 0;
padding: 0;
list-style: none;
}
h2,
h3,
a {
color: #34495e;
}
a {
text-decoration: none;
}
.active {
background-color: #d3d3d3;
border-radius: 40px;
}
.logo {
margin: 0;
font-size: 1.45em;
}
.main-nav {
margin-top: 5px;
}
.logo,
.main-nav a {
padding: 10px 15px;
text-transform: uppercase;
text-align: center;
display: block;
}
.main-nav a {
color: #34495e;
font-size: .99em;
}
.main-nav a:hover {
color: #718daa;
}
.header {
padding-top: .5em;
padding-bottom: .5em;
border: 1px solid #a2a2a2;
background-color: #f4f4f4;
-webkit-box-shadow: 0px 0px 14px 0px rgba(0,0,0,0.75);
-moz-box-shadow: 0px 0px 14px 0px rgba(0,0,0,0.75);
box-shadow: 0px 0px 14px 0px rgba(0,0,0,0.75);
-webkit-border-bottom-left-radius: 5px;
-webkit-border-bottom-right-radius: 5px;
-moz-border-bottom-left-radius: 5px;
-moz-border-bottom-right-radius: 5px;
border-bottom-left-radius: 5px;
border-bottom-right-radius: 5px;
}
@media (min-width: 769px) {
.header,
.main-nav {
display: flex;
}
.header {
flex-direction: column;
align-items: center;
.header{
width: 80%;
margin: 0 auto;
max-width: 1150px;
}
}
}
@media (min-width: 1025px) {
.header {
flex-direction: row;
justify-content: space-between;
}
}
<nav class="header">
<h2 class="logo">Logo</h2>
<ul class="main-nav">
<li><a class="active">Home</a></li>
<li><a href="#">Destinations</a></li>
<li><a href="#">Experiences</a></li>
<li><a href="#">Travel Guides</a></li>
<li><a href="#">About</a></li>
<li><a href="#">References</a></li>
</ul>
</nav>