居中
1. line-height = height 文本垂直居中
2. text-align: center; 写在父级,子级中的行标签,行块标签,文本内容水平居中
3. margin: 0 auto; 写在块元素,相对于父级水平居中
注:img 行块元素默认下边会产生一个间隙,解决方案转化为块元素
test01
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>test01</title>
<style>
* {
margin: 0;
padding: 0;
}
.item {
width: 50px;
height: 60px;
/* background-color: pink; */
text-align: center;
overflow: hidden;
float: left;
}
.item img {
width: 28px;
height: 28px;
/* img默认下方有个隔离边,修改成block会去掉 */
display: block;
margin: 5px auto;
}
.item p {
font-size: 12px;
font-weight: 200;
/* background-color: gold; */
}
</style>
</head>
<body>
<div class="item">
<img src="img/test01/1.png" alt="">
<p>话费</p>
</div>
<div class="item">
<img src="img/test01/2.png" alt="">
<p>机票</p>
</div>
<div class="item">
<img src="img/test01/3.png" alt="">
<p>酒店</p>
</div>
</body>
</html>
<!-- 居中: (10遍)
1. line-height = height 文本垂直居中
2. text-align:center 写在父级,
子级中的行元素,行块元素,文本内容水平居中
3. margin: 0 auto 写在块元素,相对于父级水平居中 -->
test02
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<