老师请检查,一行显示两个没实现
来源:3-17 编程练习
慕仙本仙_
2020-04-13 11:29:06
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
/* 在此处补充代码*/
* {
box-sizing: border-box;
padding: 0;
margin: 0;
font-family: "微软雅黑";
}
input{
cursor: pointer;
}
li {
list-style: none;
}
header{
width:100%;
height:100px;
background:#000;
display: flex;
justify-content: space-around;
}
.nav{
display: flex;
/*flex-grow: 1;*/
width:600px;
justify-content: center;
align-items: center;
color:#FFF;
}
.nav li{
flex-grow: 1;
display: flex;
justify-content: center;
align-items: center;
}
.login{
display: flex;
width:200px;
justify-content: space-around;
align-items: center;
}
.login input{
width:50px;
height:30px;
display: flex;
justify-content: center;
align-items: center;
border:none;
background:orange;
color:#FFf;
}
section{
display: flex;
justify-content: space-around;
align-items:center;
flex-wrap: wrap;
}
.section{
width:700px;
height:150px;
background: lightblue;
border-radius: 5px;
display: flex;
margin-top:20px;
justify-content: space-around;
}
.box{
display: flex;
flex-direction: column;
font-weight:bold;
}
.box p,.box div{
flex:1;
display: flex;
align-items:center;
}
.shopping{
/*background:#686868 ;*/
display: flex;
justify-content: center;
align-items: center;
}
.btn{
background: orange;
color:#Fff;
font-weight: 800;
border-radius:5px ;
width:110px;
height: 30px;
display: flex;
justify-content: center;
align-items: center;
cursor: pointer;
}
.btn:hover{
color:lightgray;
}
</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>《前端小白入门手册》</p>
<div>适用人群:没有任何前端基础的小白</div>
<div>费用:¥499</div>
</div>
<div class="shopping">
<div class="btn">加入购物车</div>
</div
</section>
</body>
</html>
1回答
同学你好,代码整体布局是不错的。测试代码效果如下
是一行显示两个的。可能由于分辨率的问题,老师这边大一些就两个显示在一行了。
建议将固定宽度700px修改为百分比,参考:
给body设置最小宽度,避免视口过小导致显示不美观:
代码中其他优化建议:
顶部右侧两个按钮可以添加圆角效果,看起来会更美观一些
如果我的回答帮到了你,欢迎采纳,祝学习愉快~
相似问题