1.根据每个省份获取城市信息,在根据每个城市信息获取区县信息。代码如下:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>三级导航页面</title>
<style>
* {
margin: 0;
padding: 0;
list-style: none;
}
/* 容器样式 */
.main{
margin-top: 20px;
margin-left: 20px;
}
/* 省份样式 */
.province {
width: 200px;
}
.province .title {
text-align: center;
height: 30px;
line-height: 30px;
background-color: rgb(13, 107, 131);
color: white;
}
/* 城市样式 */
.city {
background-color: rgb(65, 190, 221);
color: white;
line-height: 30px;
text-align: center;
}
.city>li {
cursor: pointer;
/* 相对定位 */
position: relative;
}
.city>li:hover .district{
display: block;
}
/* 区县样式 */
.district {
position: absolute;
width: 200px;
left: 200px;
top: 0px;
background-color: rgb(73, 231, 218);
display: none;
}
</style>
</head>
<body>
<div class="main">
<!-- <div class="provinc