如果三个块元素该怎么并列一行?还有块元素如何居中?
如题:如果三个块元素该怎么并列一行?还有块元素如何居中?
如题:如果三个块元素该怎么并列一行?还有块元素如何居中?
2018-05-15
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
father{
width: 500px;
height: 500px;
background: #000;
}
.son1{
height: 100px;
background: green;
}
.son2{
width:250px;
height: 200px;
background: yellow;
margin-left:auto;
margin-right:auto;
}
.son3{
height: 100px;
background: red;
}
.son2 h1{text-align:center;
line-height:200px;
margin:0;
}
</style>
</head>
<body>
<div class="father">
<div class="son1"></div>
<div class="son2">
<h1>我要居中</h1>
</div>
<div class="son3"></div>
</div>
</body>
</html>
举报