html 竖向导航栏代码,右侧再加三角箭头
时间: 2023-12-26 15:02:09 浏览: 122
html 导航栏
<html>
<head>
<style>
ul {
list-style-type: none;
margin: 0;
padding: 0;
width: 200px;
background-color: #f1f1f1;
position: fixed;
height: 100%;
overflow: auto;
}
li a {
display: block;
color: #000;
padding: 8px 16px;
text-decoration: none;
}
li a.active {
background-color: #4CAF50;
color: white;
}
li a:hover:not(.active) {
background-color: #555;
color: white;
}
.dropbtn {
padding: 8px 16px;
background-color: #f1f1f1;
color: black;
border: none;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 1;
}
.dropdown-content a {
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
}
.dropdown-content a:hover {
background-color: #f1f1f1;
}
.dropdown:hover .dropdown-content {
display: block;
}
.arrow {
float: right;
margin-right: 10px;
}
.arrow::before {
content: "\25B6";
}
</style>
</head>
<body>
<ul>
<li><a class="active" href="#home">Home</a></li>
<li class="dropdown">
<button class="dropbtn">Dropdown <span class="arrow"></span></button>
<div class="dropdown-content">
<a href="#link1">Link 1</a>
<a href="#link2">Link 2</a>
<a href="#link3">Link 3</a>
</div>
</li>
<li><a href="#about">About</a></li>
<li><a href="#contact">Contact</a></li>
</ul>
</body>
</html>
阅读全文