老师,这样对吗?

来源:3-17 编程练习

愁啥

2021-03-05 14:28:43

<!DOCTYPE html>
<html>

<head>
<meta charset="UTF-8">
<title></title>
<style>
/*在此处补充代码*/
* {
padding: 0;
margin: 0;
}

header.box {
height: 80px;
background: rgb(0, 0, 0);
display: flex;
justify-content: space-around;
align-items: center;
}

.logo {
width: 191px;
}

.logo img {
height: 57px;
}

ul {
width: 400px;
list-style: none;
display: flex;
justify-content: space-around;
}

ul li {
color: white;
width: 80px;
line-height: 80px;
}

.login {
vertical-align: middle;
line-height: 80px;
display: flex;
width: 100px;
justify-content: space-around;
}

input {
width: 44px;
height: 30px;
background-color: gold;
color: white;
border: none;
border-radius: 3px;
line-height: 20px;
}

.main {
padding-top: 10px;
height: 270px;
display: flex;
justify-content: space-around;
align-items: center;
flex-wrap: wrap;

}

.main .section {
font-size: 15px;
display: flex;
border-radius: 5px;
width: 47%;
height: 120px;
background-color: rgba(57, 145, 218, 0.527);
justify-content: space-around;
align-items: center;
}
.main .section .box{
display: flex;
height: 100px;
flex-direction: column;
display: flex;
justify-content: space-around;
}
.main .section .box div,.main .section .box p{
height: 35px;
}
.main .section .btn{
vertical-align: middle;
}
.main .section .btn{
/* //文本居中 */
text-align: center;
width: 85px;
height: 35px;
line-height: 35px;
border-radius: 4px;
color: white;
background-color: gold;
}
</style>
</head>

<body>
<!-- 头部 -->
<header class="box">
<div class="logo">
<img src="http://climg.mukewang.com/59feb59700019dab01910057.png" 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 class="main">
<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回答

好帮手慕星星

2021-03-05

同学你好,代码布局是可以的,但是在样式还需要调整:

1、img为行内元素,有文字特性,默认存在间隙,所以没有垂直居中显示

http://img.mukewang.com/climg/6041f9cf092f346803710083.jpg

建议将图片设置为块元素

http://img.mukewang.com/climg/6041fa2b09b3cf5b03040118.jpg

2、下方文字在标签中没有垂直居中显示

http://img.mukewang.com/climg/6041fa42090a79df03740061.jpg

代码中只设置了高度,没有设置行高,而字体高度小于设置的元素高度,所以导致没有垂直居中。建议将设置的高度去掉

http://img.mukewang.com/climg/6041faaa098e5ed002910105.jpg

祝学习愉快!

0

0 学习 · 15276 问题

查看课程