老师,帮我检查下代码,看哪里需要修改或优化
来源:3-17 编程练习
慕姐5289795
2021-07-19 19:14:16
问题描述:
帮我检查下代码
感觉卡片上的加入购物车按钮中文字没有垂直居中,不知道是不是错觉,使用line-height和flex的align-items: center都没有任何变化,求解
相关代码:
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
/* 在此处补充代码*/
* {
padding: 0;
margin: 0;
}
body {
width: 1000px;
/*height: 100vh;*/
}
header {
height:60px;
background-color: rgb(0, 0, 0);
display: flex;
justify-content: space-around;
align-items: center;
}
header .logo img {
height: 60px;
display: block;
}
header .nav {
list-style: none;
height: 100%;
color: white;
display: flex;
width: 300px;
}
header .nav li {
flex: 1;
display: flex;
justify-content: center;
align-items: center;
}
header .login {
flex-basis: 80px;
display: flex;
justify-content: space-between;
}
header .login input {
width: 30px;
height: 20px;
line-height: 20px;
background-color: orange;
color: white;
border: none;
border-radius: 2px;
}
.main {
height: 240px;
display: flex;
flex-wrap: wrap;
justify-content: space-around;
align-items: center;
}
.main .section {
background-color: lightblue;
width: 45%;
height: 40%;
padding: 5px;
border-radius: 5px;
display: flex;
justify-content: space-around;
align-items: center;
}
.main .section .box {
height: 100%;
display: flex;
flex-direction: column;
justify-content: space-around;
}
.main .section .shopping {
padding: 5px;
background-color: orange;
color: white;
border-radius: 5px;
}
</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 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>《从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>《前端工程师进阶全栈》</p>
<div>适用人群:有前段开发经验的童鞋</div>
<div>费用:¥1599</div>
</div>
<div class="shopping">
<div class="btn">加入购物车</div>
</div>
</div>
</section>
</body>
</html>
相关截图:
1回答
同学你好,代码中有如下问题:
1、内容没有全屏展示:
一般情况下,这种页面都是全屏展示的。
建议去掉body的width属性:
2、优化建议:
头部右侧按钮,太小了,可以增大些:
问题解答如下:
卡片中按钮的文字,稍微有点不垂直居中,因为文字垂直方向默认的对齐方式,会在中线稍微偏下的位置,但是并不明显。可以使用行高调整一下:
注意,文字在div.btn中,所以要调整div.btn的行高。也可以不调整,并不明显。
祝学习愉快!
相似问题
回答 1
回答 1
回答 1
回答 1
回答 1