CarmenLu
2018-05-20 11:48
怎么安排中间块状元素居中???
效果图

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<style>
father{
width: 500px;
height: 500px;
background: #000;
}
.son1{
height: 100px;
background: green;
}
.son2{
height: 200px;
background: yellow;
}
.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>
感觉 用一个父块 然后三个字块 把三个字块放进父块中!
初识HTML(5)+CSS(3)
1230234 学习 · 19084 问题
相似问题