2022年3月17号
今天学习了网页前端的二级菜单栏的编写过程,当中还是遇到了很多问题:
- 首先当高度或者宽度不够的时候,浮动属性值会失效,所以,当你的浮动属性值失效的时候,你可以检查一下宽度和高度是否正确。
- 其次,在写一个页面的时候,首先要将其默认值去掉,直接设置为0,不然会干扰你的结果。
- 再者,当你出现错误的时候,你可以点开网页的查看工具,去看看你写的代码为什么不起作用,当现实属性值无效的时候,就是你的代码写错了,不要怀疑。再更改。当你写的属性值被画了横线的时候,说明你后面误写了该属性,或者是更高级别的css中包含了这个属性,你就必须检查你都style中的属性。
- 最后,是一些细节问题,可以设置行高将内容上下居中;属性:属性值1 属性值2 属性值3 中间是没有逗号的,要直接用空格隔开;要注意一些小细节,选着正确的类别。
代码
<!DOCTYPE html>
<html lang="en">
<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>Document</title>
<style>
*{
margin:0%;
padding: 0%;
}
ul{
list-style: none;
}
.box{
width: 300px;
margin: 0,auto;
}
.box .item{
float:left;
width: 148px;
text-align: center;
border: 1px solid blue;
background-color: blue;
line-height: 40px;
color:white;
}
.item:hover {
background-color: lightblue;
}
.item ul{
background-color: white;
color:black;
display: none;
}
.item:hover ul{
display: block;
}
.item li:hover {
color:blue;
}
</style>
</head>
<body>
<ul class="box">
<li class="item">视频教程
<ul>
<li>全部视频教程</li>
<li>HTML5视频教程</li>
<li>java视频教程</li>
<li>python视频教程</li>
</ul>
</li>
<li class="item">认证考试
<ul>
<li>PMP</li>
<li>红帽</li>
</ul>
</li>
</ul>
</body>
</html>