麻烦老师帮我检查一下看看代码有问题不
来源:4-7 编程练习
慕圣4094179
2019-02-02 09:11:20
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>display属性</title>
<style type="text/css">
/*样式补充*/
li{list-style:none;}
body,div,ul,h3{padding:0px;margin:0px;}
.big{background:#f2f4f6;border:1px #ececec solid;width:150px;
margin:30px auto;
}
h3{ padding:5px 50px;border-bottom:1px #ececec solid;}
.elec{display:none;
background:#fff;
width:100%;
}
.div1:hover ul{display:inline-block;}
ul li{padding:10px 50px;}
.wash{display:none;
background:#fff;
width:100%;
}
.div2:hover ul{display:inline-block;}
.clothes{display:none;
background:#fff;
width:100%;
}
.div3:hover ul{display:inline-block;}
</style>
</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>
1回答
山河远阔ZZ
2019-02-02
同学你好,效果实现是没有问题的哦,不过老师建议把hover里面的inline-block变成block,因为block会将元素显示为块级元素,而ul是块元素,这样不会改变ul本身的特性了。
参考下图:
如果帮助到了你,欢迎采纳。
祝学习愉快!
相似问题