麻烦老师检查一下
来源:4-7 编程练习
慕桂英6102712
2019-11-03 13:55:47
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<link href="style.css" rel="stylesheet" type="text/css">
</head>
<body>
<div class="big">
<div class="div1">
<h3>家电</h3>
<ul class="elec">
<li>冰箱</li>
<li>洗衣机</li>
<li>空调</li>
</ul>
</div>
<div class="div2">
<h3>洗护</h3>
<ul class="wash">
<li>洗衣液</li>
<li>消毒液</li>
<li>柔顺剂</li>
</ul>
</div>
<div class="div3">
<h3>衣物</h3>
<ul class="clothes">
<li>衬衫</li>
<li>裤子</li>
<li>卫衣</li>
</ul>
</div>
</div>
</body>
</html>
*{
padding:0px;
margin: 0px;
}
div.big{
background-color: #efefef;
width: 200px;
border:1px solid #5f5f5f;
}
.div1,.div2{
border-bottom: 1px solid #5f5f5f;
}
ul li{
display:none
}
h3{
text-align: center;
padding: 5px;
}
div.div1:hover .elec li{
display:block;
text-align: center;
background-color: white;
line-height: 30px;
}
div.div2:hover .wash li{
display:block;
text-align: center;
background-color: white;
line-height: 30px;
}
div.div3:hover .clothes li{
display:block;
text-align: center;
background-color: white;
line-height: 30px;
}
1回答
同学你好,
1、下拉效果实现没有问题,还有一点需要完善:
给外层大盒子添加margin属性,如下:
2、优化建议:相同的样式可以进行合并,参考:
祝学习愉快!欢迎采纳~