5-2 请问这样效果实现了吗?有无需要改进的地方
来源:5-2 编程练习
RogerLeung
2018-04-26 20:43:47
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
/* 在此处补充代码*/
*{
padding: 0;
margin: 0;
}
header{
display: flex;
align-items: center;
justify-content: space-around;
background-color: #000;
}
.nav{
width: 400px;
list-style-type: none;
display: flex;
align-items: center;
color: white;
font-size: 20px;
justify-content: space-between;
}
.login{
width:150px;
display: flex;
justify-content: space-around;
}
.login input{
background-color: orange;
color: white;
border: none;
padding: 5px 10px;
}
header,
section{
min-width: 1000px;
}
section{
display: flex;
justify-content: space-around;
flex-wrap: wrap;
}
section .section{
display: flex;
box-sizing: border-box;
width: 480px;
height: 150px;
background-color: #abcdef;
border-radius: 5px;
margin-top: 20px;
padding: 5px 20px;
justify-content: space-around;
font-weight: bold;
}
section .section .box{
display: flex;
flex-direction: column;
justify-content: center;
line-height: 35px;
}
section .section .shopping{
display: flex;
align-items: center;
}
section .section .shopping .btn{
height: 20px;
color: white;
background-color: orange;
border-radius: 5px;
padding: 5px 12px;
}
section .section .shopping .btn:hover,
input[type="button"]:hover{
background-color: green;
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>《前端小白入门手册》</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回答
好帮手慕星星
2018-04-27
经测试下半部分是在一行显示的哦,如下:

可能你自己测试的时候是两排显示的,但是每个显示器的分辨率不同,显示效果也会不同,建议section宽度设置成百分比就可以了,参考:

自己再测试下,祝学习愉快~~
相似问题