请老师检查代码
来源:3-17 编程练习
激情的樱木花道
2021-07-29 22:49:20
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title></title>
<style>
* {
margin: 0;
padding: 0;
list-style: none;
}
header {
width: 100%;
height: 100px;
background-color: #000;
display: flex;
justify-content: space-around;
align-items: center;
}
.nav {
display: flex;
}
.nav li {
padding: 7px 40px;
color: white;
font-size: 18px;
cursor: pointer;
}
.nav li:hover {
background-color: #ccc;
}
.login input {
padding: 4px;
margin-right: 15px;
background-color: orange;
border: none;
border-radius: 4px;
color: white;
cursor: pointer;
}
section {
height: 350px;
display: flex;
flex-wrap: wrap;
justify-content: space-around;
}
.section {
width: 650px;
height: 140px;
background-color: #87cefa;
display: flex;
justify-content: space-around;
align-items: center;
margin-top: 20px;
}
.section .box {
height: 140px;
display: flex;
flex-direction: column;
justify-content: space-around;
}
.section .btn {
padding: 10px 8px;
background-color: orange;
border-radius: 5px;
color: white;
}
</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>《前端小白入门手册》</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回答
同学你好,代码布局是可以的,样式还可以进行优化:
1、logo图与父盒子之间有间隙
这是因为图片为行内元素,有文字特性,默认存在间隙。建议将图片设置为块元素
2、效果图中每项内容盒子是圆角效果
建议也添加上。并且建议每项盒子设置宽度为百分比,这样页面宽度减小的时候,也能一行显示两个,参考
祝学习愉快!
相似问题