老师,麻烦看一下有没有什么要优化的地方

来源:4-7 编程练习

慕码人0228079

2020-09-07 22:56:45

<!DOCTYPE html>

<html>

<head lang="en">

<meta charset="UTF-8">

<title>display属性</title>

<style type="text/css">

/*样式补充*/

body,div,h1,h2,h3,h4,h5,h6,ul,li{

margin: 0;

padding: 0;

list-style: none;

}

.big{

margin: 0 auto;

width: 220px;

border: 1px #eaeaea solid;

}

h3{

width: 100%;

height: 30px;

font-size: 16px;

border-bottom: 1px #eaeaea solid;

border-top: 1px #eaeaea solid;

background-color: #d9d6c3;

text-align: center;

line-height: 30px;

}

.elec li,.wash li,.clothes li{

width: 100%;

height: 30px;

font-size: 16px;

line-height: 30px;

text-align: center;

display: none;

}

.div1:hover .elec li,.div2:hover .wash li,.div3:hover .clothes li{

display: 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回答

好帮手慕鹤

2020-09-08

同学你好,代码没有问题。

不过页面中的效果可以进行优化,如下:

http://img.mukewang.com/climg/5f56e89f0973276d02140114.jpg

可以把内容设置在同一个起点显示,通过给它们设置文本缩进:text-indent来实现这个效果,缩进大小可以自行设置哦,例如:

http://img.mukewang.com/climg/5f56ee8a09c04f9e05550268.jpg

如果我的回答帮助到了你,欢迎采纳,祝学习愉快~   

0

0 学习 · 40143 问题

查看课程