使用CSS将导航栏中的链接居中
要使导航栏中的链接居中,您需要在“<li>”中添加“text-align:center”
示例
<!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
width: 200px;
}
li a {
display: block;
background-color: #F0E7E7;
}
.active {
background-color: #4CAF50;
color: white;
}
li {
text-align: center;
border-bottom: 1px solid #555;
}
</style>
</head>
<body>
<ul>
<li><a href = "#home">Home</a></li>
<li><a href = "#company" class = "active">Company</a></li>
<li><a href = "#product">Product</a></li>
<li><a href = "#services">Services</a></li>
<li><a href = "#contact">Contact</a></li>
</ul>
</body>
</html>热门推荐
10 对同学祝福语 简短独特
11 对司机的祝福语简短
12 兔年祝福语简短100字
13 生日祝福语古语简短创意
14 简短正能量生日祝福语
15 高考给舍友祝福语简短
16 老师高考后祝福语 简短
17 迎新祝福语简短20字
18 今年节日祝福语简短