编程4-7,麻烦看下哪里错了
来源:4-7 编程练习
weixin_慕用5152390
2019-08-06 21:15:31
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>display属性</title>
<style type="text/css">
div,h3,ul,li{margin: 0px;padding: 0px;font-family: "微软雅黑";text-align: center;}
/*样式补充*/
.wash,.elec,.clothes{display: none;}
.big{background-color: gray;width: 220px;border:1px #ececec solid;margin: 0 auto; }
.div1,.div2,.div3{
width: 100%;
font-size: 14px;
border-bottom: 2px black solid;
}
a{text-decoration: none;}
a:hover h3 .elec{display: block;}
</style>
</head>
<body>
<div class="big">
<div class="div1">
<a href="#"><h3>家电</h3></a>
<ul class="elec">
<li>冰箱</li>
<li>洗衣机</li>
<li>空调</li>
</ul>
</div>
<div class="div2">
<a href="#"><h3>洗护</h3></a>
<ul class="wash">
<li>洗衣液</li>
<li>消毒液</li>
<li>柔顺剂</li>
</ul>
</div>
<div class="div3">
<a href="#"><h3>衣物</h3></a>
<ul class="clothes">
<li>衬衫</li>
<li>裤子</li>
<li>卫衣</li>
</ul>
</div>
</div>
</body>
</html>
1回答
好帮手慕夭夭
2019-08-07
你好同学,是选择器不对,如下表示移入a标签,让它子元素h3里面的.elec设置样式,即.elec是a的孙子元素。
但是从结构上看 ,elec与a是兄弟关系。
所以选择器如下修改:
祝学习愉快,望采纳。
相似问题