我正在尝试订购我的导航栏,以便顺序是导航,然后是按钮,然后是 h1。我在这里关注一个教程,它是 youtuber 提供的第三个选项。h1 应该一直推到右侧。出于某种原因,弹性订单将无法在标题中工作并以正确的方式对齐。
*{
box-sizing: border-box;
padding:0;
margin:0;
}
body{
background-color: rgb(54, 54, 54);
font-family: sans-serif;
color: white;
}
li, a, button{
font-weight: 500;
font-size: 16px;
font-family: sans-serif;
color: rgb(255, 255, 255);
text-decoration: none;
}
header{
display: flex;
justify-content: space-between;
align-items: center;
height: 15vh;
padding: 30px 10%;
}
h1{
cursor: pointer;
margin-left: auto;
order: 3;
}
nav{
order: 1;
}
ul{
list-style: none;
}
ul li{
display: inline-block;
padding: 0 20px;
}
ul li a{
transition: all 0.3s ease;
}
ul li a:hover{
color: pink;
}
.cta{
order: 2;
}
button{
padding: 9px 25px;
background-color: white;
color: rgb(54, 54, 54);
border: none;
border-radius: 50px;
cursor: pointer;
transition: all 0.3s ease;
}
button:hover{
background-color: pink;
color: white;
}
<header>
<a href="/index.html"><h1>Loonieville</h1></a>
<nav>
<ul class='navlinks'>
<li><a href="/">Main St</a></li>
<li><a href="/">Town Hall</a></li>
<li><a href="/">Downtown</a></li>
</ul>
</nav>
<a href="" class='cta'><button>
Contact
</button></a>
</header>
