老师这样对吗
来源:3-17 编程练习
咸鱼王派大星
2021-06-05 07:37:23
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
/* 在此处补充代码*/
header{
display: flex;
justify-content: space-around;
background-color: black;
}
.nav{
color:white;
display: flex;
justify-content: space-around;
width: 40%;
align-items: center;
list-style: none;
margin-left: -4%;
}
.nav li{
font-size: 22px;
}
.login{
display: flex;
align-items: center;
justify-content: space-around;
width: 130px;
}
.login input{
background-color: orange;
color: white;
height: 29px;
border-radius: 5px;
border: none;
}
section{
display: flex;
justify-content: space-around;
align-items: center;
}
section .section{
background-color: rgba(127, 219, 255, 0.829);
border-radius: 10px;
margin-top: 10px;
width: 40%;
display: flex;
justify-content: space-around;
align-items: center;
}
section .section .box{
height: 200px;
display: flex;
flex-direction: column;
justify-content: space-around;
}
section .section .shopping{
background-color:orange;
color: white;
border-radius: 5px;
height: 40px;
width: 100px;
display: flex;
align-items: center;
justify-content: center;
font-size: 15px;
}
</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>
</section>
</body>
</html>
1回答
同学你好,代码实现存在以下几点问题,建议优化:
(1)书写css代码之前,建议先将元素默认的margin和padding清除,参考如下
(2)任务要求:主体内容的卡片一行只能显示两个,当放置四个div卡片盒子时,没有换行显示,如图
建议:给section盒子设置flex-wrap换行属性即可,参考如下
祝学习愉快!
相似问题