老师,这样写可以吗?
来源:3-17 编程练习
慕大仙er
2021-05-31 16:09:50
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
/* 在此处补充代码*/
*{
padding:0;
margin:0;
}
li{
list-style: none;
}
header, .logo, .nav, .login, section, .section, .section .box, .section .shopping{
display: flex;
}
header{
height:40px;
justify-content: space-around;
align-items: center;
background-color: black;
}
.logo img{
height:40px;
}
.nav{
color:white;
width:520px;
}
.nav li{
/* 平分空间 */
flex:1;
}
.login{
width:100px;
box-sizing:border-box;
}
.login input{
flex:1;
margin-left:10px;
width:50px;
border:none;
outline:none;
color:white;
background-color: orange;
border-radius: 2px;
cursor: pointer;
}
section{
width: 100%;
justify-content:space-around;
align-items: center;
flex-wrap: wrap;
height:160px;
}
.section{
background-color:lightblue;
width: 45%;
justify-content: space-around;
align-items: center;
font-size: 12px;
border-radius: 8px;
}
.section .box{
width:70%;
flex-direction: column;
padding:8px;
box-sizing: border-box;
}
.section .shopping{
justify-content: center;
align-items: center;
background-color: orange;
color:white;
width:90px;
height:28px;
border-radius: 4px;
}
</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>《从H5网页开发到移动端响应式开发》</p>
<div>适用人群:有html、css、js、jQ基础的童鞋</div>
<div>费用:¥599</div>
</div>
<div class="shopping">
<div class="btn">加入购物车</div>
</div>
</div>
<div class="section">
<div class="box">
<p>《从H5网页开发到移动端响应式开发》</p>
<div>适用人群:有html、css、js、jQ基础的童鞋</div>
<div>费用:¥599</div>
</div>
<div class="shopping">
<div class="btn">加入购物车</div>
</div>
</div>
</section>
</body>
</html>
1回答
好帮手慕星星
2021-05-31
同学你好,代码布局可以,建议在样式上进行优化:
1、顶部导航和按钮分布不均匀
li文字默认在左侧显示,所有右侧有很大空隙,建议设置文本居中
右侧按钮可以设置左右两侧间距,然后添加上下padding值,看着更美观一些
2、底部内容高度以及文字有些小,建议去掉section盒子高度,给子元素.section添加高度以及上下间距,去掉12px字体,并且给box盒子设置flex,参考
自己再测试下,祝学习愉快!
相似问题