如何使用 CSS 创建垂直菜单?
cssweb developmentfront end technology更新于 2025/9/26 20:28:17
以下是使用 CSS 制作垂直菜单的代码 −
示例
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<style>
.Menu {
width: 200px;
}
.links {
background-color: rgb(251, 255, 188);
color: black;
display: block;
padding: 12px;
text-decoration: none;
}
.links:hover {
background-color: rgb(85, 85, 85);
color:white;
}
.links.selected {
background-color: rgb(0, 0, 0);
color: white;
}
</style>
</head>
<body>
<div class="Menu">
<a href="#" class="links selected">About Us</a>
<a class="links" href="#">Social Links</a>
<a class="links "href="#">Visit Us</a>
<a class="links" href="#">More info</a>
<a class="links" href="#">Phone Number</a>
</div>
</body>
</html>
输出
上述代码将产生以下输出 −

相关文章
有用资源
css 参考教程 - 该教程包含有关 css 的更多信息:https://www.cainiaomax.com/css/

