我试图在导航栏上将多个 a 标签彼此相邻对齐,但是每当我将它们对齐在中心时,它们就会彼此堆叠在顶部。我尝试了 disply: flex;但这将文本左对齐
body {
overflow-x: hidden;
}
.navbar {
background-color: #ffffff;
border-bottom: 2px solid #000000;
margin: 0px -2000px;
padding: 0px 2000px;
}
.cent {
text-align: center;
}
.navbar a {
display: block;
color: #000000;
padding: 14px;
text-decoration: none;
}
<html>
<head>
<title>entertainment</title>
<link rel="stylesheet" href="entertainment.css">
<script src="entertainment.js"></script>
</head>
<body>
<div class="navbar">
<div class="cent">
<a href="#home">Home</a>
<a href="#news">News</a>
<a href="#contact">Contact</a>
</div>
</div>
</body>
</html>
侃侃尔雅
MMMHUHU
慕妹3242003
RISEBY
相关分类