写一个左侧带有可伸缩的2级导航栏的html代码
时间: 2023-03-24 13:03:15 浏览: 153
行业文档-设计装置-一种带有可伸缩教鞭的黑板擦.zip
<!DOCTYPE html>
<html>
<head>
<title>可伸缩的2级导航栏</title>
<style>
/* 一级导航样式 */
.navbar {
background-color: #333;
overflow: hidden;
}
.navbar a {
float: left;
color: white;
text-align: center;
padding: 14px 16px;
text-decoration: none;
font-size: 17px;
}
.navbar a:hover {
background-color: #ddd;
color: black;
}
/* 二级导航样式 */
.dropdown {
float: left;
overflow: hidden;
}
.dropdown .dropbtn {
font-size: 17px;
border: none;
outline: none;
color: white;
padding: 14px 16px;
background-color: inherit;
font-family: inherit;
margin: ;
}
.navbar a:hover, .dropdown:hover .dropbtn {
background-color: #ddd;
color: black;
}
.dropdown-content {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 160px;
box-shadow: px 8px 16px px rgba(,,,.2);
z-index: 1;
}
.dropdown-content a {
float: none;
color: black;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
}
.dropdown-content a:hover {
background-color: #ddd;
}
.dropdown:hover .dropdown-content {
display: block;
}
</style>
</head>
<body>
<!-- 一级导航 -->
<div class="navbar">
<a href="#home">首页</a>
<a href="#news">新闻</a>
<div class="dropdown">
<button class="dropbtn">产品
<i class="fa fa-caret-down"></i>
</button>
<!-- 二级导航 -->
<div class="dropdown-content">
<a href="#">产品1</a>
<a href="#">产品2</a>
<a href="#">产品3</a>
</div>
</div>
<a href="#contact">联系我们</a>
</div>
</body>
</html>
阅读全文