老师请帮我改进以下,看哪里可以优化?

来源:3-17 编程练习

张月白

2021-01-08 10:19:54

​<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
* {
margin:0;
padding:0;
}
header{
display:flex;
justify-content:space-around;
align-items:center;
background:black;
color:#fff;
}
.nav {
list-style:none;
display:flex;
justify-content:space-around;
}
.nav>li{
/*可以设置width撑开间隙*/
width:80px;
text-align:center;
}
input{
background-color:orange;
color:white;
border:none;
border-radius:5px;
}
section {
display:flex;
justify-content:space-around;
flex-wrap:wrap;
}
.section{
border-radius:5px;
background-color:#0cc;
flex:1;
margin:2%;
min-width:30%;
display:flex;
justify-content:space-around;
align-items:center;
}
/*.box{
display:flex;
flex-direction:column;
justify-content:space-around;
}*/
.box p{
padding:5% 0 5% 0;
}
.box div{
padding:5% 0 5% 0;
}
.shopping{
color:#fff;
background-color:orange;
padding:2%;
border-radius:5px;
}
</style>
</head>
<body>
<header>
<div class="logo">
<img src="http://climg.mukewang.com/59feb59700019dab01910057.png" alt="">
</div>
<ul class="nav">
<li>课程</li>
<li>路径</li>
<li>猿问</li>
<li>手记</li>
</ul>
<div class="login">
<input type="button" value="登录">
<input type="button" value="注册">
</div>
</header>
<section>
<div class="section">
<div class="box">
<p>《前端小白入门手册》</p>
<div>适用人群:没有任何前端基础的小白</div>
<div>费用:¥499</div>
</div>
<div class="shopping">
<div class="btn">加入购物车</div>
</div>
</div>
<div class="section">
<div class="box">
<p>《HTML5月CSS3实现动态网页》</p>
<div>适用人群:有html和css基础的童鞋</div>
<div>费用:¥599</div>
</div>
<div class="shopping">
<div class="btn">加入购物车</div>
</div>
</div>
<div class="section">
<div class="box">
<p>《前端小白入门手册》</p>
<div>适用人群:没有任何前端基础的小白</div>
<div>费用:¥499</div>
</div>
<div class="shopping">
<div class="btn">加入购物车</div>
</div>
</div>
<div class="section">
<div class="box">
<p>《HTML5月CSS3实现动态网页》</p>
<div>适用人群:有html和css基础的童鞋</div>
<div>费用:¥599</div>
</div>
<div class="shopping">
<div class="btn">加入购物车</div>
</div>
</div>
</section>
</body>
</html>


写回答

1回答

好帮手慕星星

2021-01-08

同学你好,代码布局是可以的,样式上还需要进行优化:

1、页面顶部有空白部分

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

这是因为粘贴代码顶部有空行

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

删除掉就可以了。

2、顶部logo与父盒子之间有间隙

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

这是因为图片为行内元素,有文字特性,默认存在间隙。建议将图片设置为块元素

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

3、顶部右侧两个按钮看起来不美观,可以添加padding值进行美化

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

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

祝学习愉快!

0

0 学习 · 6815 问题

查看课程