使用 CSS 设置导航栏边框
cssweb developmentfront end technology更新于 2025/6/6 0:12:17
要添加导航栏边框,请将 border 设置为 <ul>
ul {
border: 2px solid blue;
}
示例
您可以尝试运行以下代码来设置边框
<!DOCTYPE html>
<html>
<head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
width: 200px;
border: 2px solid blue;
}
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>
相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

