简单的Web前端二级导航栏示例:
DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>二级导航栏title>
<style type="text/css">
*{
margin: 0;
padding: 0;
/* 设置自动内减 */
box-sizing: border-box;
}
/* 取消li标签的点样式效果 */
li{
list-style: none;
}
a{
text-decoration: none;
}
.nav{
width: 1400px;
height: 100px;
}
.box>li{
width: 25%;
height: 60px;
float: left;
}
.box>li>a{
width: 100%;
height: 60px;
display: block;
background-color: #2c7d2c;
/* 字体设置 */
font-size: 22px;
font-weight: 800;
color: #ffffff;
/* 内容布局 */
text-align: center;
line-height: 60px;
}
.box>li:hover>a{
color: #414141;
background-color: #79fb79;
}
.box_lev2>li{
width: 100%;
height: 45px;
overflow: hidden;
}
.box_lev2>li>a{
width: 100%;
height: 45px;
display: block;
background-color: #01703a;
/* 字体设置 */
font-size: 18px;
font-weight: 800;
color: #ffffff;
/* 内容布局 */
text-align: center;
line-height: 45px;
}
.box_lev2{
display: none;
}
.box_lev2>li>a:hover{
background-color: #34e590;
}
.box>li:hover .box_lev2{
display: block;
}
style>
head>
<body>
<div class="nav">
<ul class="box">
<li><a href="">1导航栏a>
<ul class="box_lev2">
<li><a href="">1二级导航a>li>
<li><a href="">2二级导航a>li>
<li><a href="">3二级导航a>li>
ul>
li>
<li><a href="">2导航栏a>li>
<li><a href="">3导航栏a>li>
<li><a href="">4导航栏a>li>
ul>
div>
body>
html>