css-让2个span标签水平居中
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style>
/* 总结:*/
.d1{
width: 300px;
height: 100px;
background-color: pink;
}
.d2{
/* 1.给span父级dd加宽度随便, */
width: 80%;
background-color: blue;
/* 让d2相对d1 盒子水平居中 */
margin: 0 auto;
/* 让文字居中 */
text-align: center;
}
.d2 span{
width: 100px;
height: 20px;
background-color: purple;
}
</style>
</head>
<body>
<div class="d1">
<div class="d2">
<span>我是行内块1</span>
<span>我是行内块2</span>
</div>
</div>
</body>
</html>
记录技巧,个人笔记