代码如下
DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>导航栏下拉title>
<link rel="stylesheet" href="导航栏下拉.css">
<style>
ul{
width: 400px;
height: 30px;
line-height: 30px;
background-color: rgb(6, 7, 7);
}
ul li{
list-style: none;
float: left;
}
a{
color: white;
padding: 20px;
margin: 0px;
text-decoration: none;
}
.nav1 {
position: relative;
display: inline-block;
}
.nav2 {
display: none;
position: absolute;
background-color: #f9f9f9;
min-width: 81px;
}
.nav2 a {
color: black;
padding: 12px 16px;
display: block;
}
.nav2 a:hover {
background-color: #da8181
}
.nav1:hover .nav2 {
display: block;
}
.nav1:hover,li:hover{
background-color: #12adb8;
}
style>
head>
<body>
<ul>
<li><a href="#">内容1a>li>
<li><a href="#">内容2a>li>
<li><a href="#">内容3a>li>
<div class="nav1">
<a href="#" class="cont">内容4a>
<div class="nav2">
<a href="#">box1a>
<a href="#">box2a>
<a href="#">box3a>
<a href="#">box4a>
div>
div>
ul>
html>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74