麻烦老师检查下,代码有哪些地方需要优化的
来源:3-17 编程练习
慕的地9277935
2021-03-23 16:27:55
相关代码:
<!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-color: #000;
}
header .nav {
list-style: none;
color: #fff;
font-size: 24px;
width: 500px;
display: flex;
justify-content: space-around;
}
header .login {
width: 150px;
display: flex;
justify-content: space-around;
}
header .login input {
font-size: 20px;
border: none;
outline: none;
background-color: orange;
color: #fff;
border-radius: 4px 4px;
padding: 3px;
cursor: pointer;
}
section {
display: flex;
flex-wrap: wrap;
justify-content: space-around;
align-content: space-around;
height: 320px;
padding-top: 5px;
}
section .section {
width: 45%;
background-color: rgb(155, 217, 247);
height: 150px;
border-radius: 5px;
display: flex;
justify-content: space-around;
}
section .section .box {
display: flex;
flex-direction: column;
justify-content: space-around;
}
section .section .shopping {
display: flex;
align-items: center;
}
section .section .shopping .btn {
width: 100px;
height: 40px;
line-height: 40px;
text-align: center;
background-color: orange;
color: #fff;
border-radius: 5px;
font-weight: bold;
cursor: pointer;
}
</style>
</head>
<body>
<!-- 头部 -->
<header>
<div class="logo">
<img src="http://climg.mukewang.com/59197ab000014f1503000100.jpg" 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>《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>《HTML5月CSS3实现动态网页》</p>
<div>适用人群:有html和css基础的童鞋</div>
<div>费用:¥599</div>
</div>
<div class="shopping">
<div class="btn">加入购物车</div>
</div>
</div>
</section>
</body>
</html>
1回答
同学你好,代码布局是可以的。建议logo处样式进行优化:
图片与父盒子之间有间隙
这是因为图片为行内元素,有文字特性,默认存在间隙。建议将图片设置为块元素
祝学习愉快!
相似问题
回答 1
回答 1
回答 1
回答 1
回答 1