老师帮忙看下改进的地方
来源:3-17 编程练习
慕妹4337267
2021-03-18 02:25:56
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
body{
padding: 0;
margin: 0;
}
header{
height: 100px;
color: white;
background: black;
width: 100%;
display: flex;
align-items: center;
}
img{
align-self: center;
margin-left: 25%;
}
.logo{
flex-grow: 1;
display: flex;
}
.login{
display: flex;
align-items: center;
justify-content: center;
flex-grow: 1;
}
.login input{
margin-left: 20px;
background: orange;
border-radius: 10%;
color: white;
}
ul{
flex-grow: 1;
display: flex;
justify-content: center;
}
li{
flex-grow: 1;
font-size: 24px;
list-style: none;
}
section{
margin-top: 50px;
display: flex;
width: 100%;
justify-content: space-around;
flex-wrap: wrap;
}
.section{
margin-top: 10px;
width: 40%;
background-color: rgb(1, 189, 247);
border-radius: 10px;
display: flex;
height: 150px;
justify-content: space-around;
}
.btn{
background: orange;
}
.box,.shopping{
display: flex;
}
.box{
flex-direction: column;
justify-content: space-around;
}
.shopping{
align-items: center;
}
.shopping .btn{
border-radius: 10px;
line-height: 50px;
text-align: center;
width: 120px;
height: 50px;
}
</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、可以参考如下步骤,简化代码书写。
给header添加justify-content:space-around;属性,调整元素水平方向的布局样式。
可以去掉给logo图设置的css样式
以及给login设置flex-grow属性
调整ul的样式
2、按钮会有默认的边框样式,效果不美观,如下图所示:
建议优化:
3、卡片中的文字内容整体没有垂直居中显示
原因:p标签默认有上下外边距
建议:去掉p标签的外边距,由于body标签选择器只针对于body元素,所以可以调整为通配符*,去掉所有元素的内外边距,这样就不需要单独给p标签设置样式了。
4、建议参考下图调整下卡片的的背景颜色,以及按钮上的文字颜色,会更加符合练习效果图。
祝学习愉快~
相似问题
回答 1
回答 1
回答 1
回答 1
回答 1