Html 如何使导航链接在页面中均匀分布并居中?

Html 如何使导航链接在页面中均匀分布并居中?,html,css,button,html-lists,nav,Html,Css,Button,Html Lists,Nav,我是一个初学者,我正在为我的一个学校网站项目编写一个网站。我正在尝试设置标题样式,使其看起来像这样: 但是导航和“注册图书卡”按钮给了我一些问题。我想将按钮移到它位于顶部图标下方,但按钮一直向左移动。我尝试了浮动:对,但似乎不起作用。这是我的html和css。 谢谢 只需使用flexbox。这是你的新css nav { background-color: #13DEA9; width: 100%; height: 60px; } nav ul { height

我是一个初学者,我正在为我的一个学校网站项目编写一个网站。我正在尝试设置标题样式,使其看起来像这样:

但是导航和“注册图书卡”按钮给了我一些问题。我想将按钮移到它位于顶部图标下方,但按钮一直向左移动。我尝试了浮动:对,但似乎不起作用。这是我的html和css。 谢谢


只需使用flexbox。这是你的新css

nav {
    background-color: #13DEA9;
    width: 100%;
    height: 60px;
}

nav ul {
    height: 100%;
    display: flex;
    justify-content: space-around;
    align-items: center;
}

nav ul li {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    text-align: center;
    list-style: none;
}

nav ul li a {
    text-decoration: none;
    color: white;
}
这是一把JS小提琴:


此外,我还为导航添加了一个height属性,您可以将其设置为您想要的任何值,并且它也将保持垂直居中。

这也是因为它适用于学校和图书馆。如果你想在你的项目中获得A+++,就要研究“网页设计的可访问性”。这可以确保有听力和视力问题的人可以使用您的网站。简单的方法,没问题。如果我的答案“回答”了你的问题,请勾选“绿色支票”。谢谢
* {
-webkit-box-sizing: border-box; 
-moz-box-sizing: border-box; 
 box-sizing: border-box; 
 margin: 0;
 padding: 0;
}

.clearfix:after{
content:"";
display: table;
clear: both;
}

header{
width: 1200px;
margin: 0 auto;
margin-bottom: 40px;
}


.logo{
float: left;
width: 400px;
margin-top: 30px;
}

.icons{
width: 45px;
padding: 10px;
}


.left{
float:left;
}
.right{
float: right;
}

button {
background-color: #3399CC;
border: none;
border-radius: 4px;
color: #fff;
padding: 8px;
width: 250px;
text-align: center;
text-decoration: none;
font-size: 14px;
margin-top: 70px;
font-family:'Poppins', sans-serif;
font-weight: 500;
cursor: pointer;
}

nav{
background-color: #13DEA9;
width: 100%;
}
nav ul{
padding: 15px;


}

nav ul li{
font-family: 'Poppins', sans-serif;
font-weight: 600;
text-align: center;
list-style: none;
display: inline;


}

nav ul li a{
text-decoration: none;
margin: 70px;
color: white;


}
nav {
    background-color: #13DEA9;
    width: 100%;
    height: 60px;
}

nav ul {
    height: 100%;
    display: flex;
    justify-content: space-around;
    align-items: center;
}

nav ul li {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    text-align: center;
    list-style: none;
}

nav ul li a {
    text-decoration: none;
    color: white;
}