第三课-盒子模型-导航栏
程序员文章站
2022-03-24 09:54:24
...
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>盒子模型-导航栏</title>
<style>
ul,li,body{
padding: 0;
margin: 0;
box-sizing: border-box;
}
a{
text-decoration: none;
color: #666;
display: inline-block;
text-align: center;
padding: 20px 40px;
width: 100px;
}
li{
list-style: none;
}
nav>ul{
background: rgb(241, 224, 224);
display: flex;
justify-content: center;
position: relative;
}
nav>ul>li:hover{
background: rgb(236, 135, 135);
}
nav>ul>li>ul>li:hover{
background: rgb(236, 135, 135);
}
nav>ul>li:hover>ul{
display: block;
}
nav>ul>li>ul{
background: rgb(241, 224, 224);
position: absolute;
display: none;
}
</style>
</head>
<body>
<nav>
<ul>
<li><a href="">首页</a></li>
<li><a href="">前端学习</a>
<ul>
<li><a href="">html</a></li>
<li><a href="">css</a></li>
<li><a href="">javascript</a></li>
</ul>
</li>
<li><a href="">后端学习</a>
<li><a href="">我的</a>
<ul>
<li><a href="">资料修改</a></li>
<li><a href="">退出登录</a></li>
</ul>
</li>
</ul>
</nav>
</body>
</html>
上一篇: php对象如何转成数组
下一篇: php hello world
推荐阅读