我嘗試了很多東西,但我仍然是HTML和CSS的初學(xué)者,我想知道是否有人知道為什么列表不在導(dǎo)航欄的中心。
<!DOCTYPE html>
<html lang="en">
<head>
<link href="https://fonts.googleapis.com/css2?family=Merriweather+Sans&display=swap" rel="stylesheet">
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<div class="bar">
<ul class="words">
<li class ="Keyboards">Keyboards</li>
<li class ="Accessories">Accessories</li>
<li class ="In_Stock">In Stock</li>
<li class ="Group_Buy">Group Buy</li>
<li class ="Support">Support</li>
</ul>
</div>
</head>
<body>
</body>
</html>
*{
margin: 0;
padding: 0;
}
body{
background-color: rgb(41, 41, 41);
font-family: 'Merriweather Sans', sans-serif;
font-style: bold;
}
.bar{
background-color: rgb(69, 69, 69);
height: 75px;
}
li{
display: inline-block;
padding-left: 10px;
padding-right: 10px;
font-size: 25px;
margin: auto;
}
我試過很多邊距和顯示flex。還是沒用
試試這個(gè):
.bar{
width: 100%;
display: flex;
justify-content: center;
align-items: center;
background-color: rgb(69, 69, 69);
height: 75px;
}
.words{
width: 30%;
}
你可以用類單詞改變ul元素的寬度。