应用场景:
1.弹框水平垂直居中
2.标题文字水平垂直居中于banner图中
<!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>Document</title>
<style>
.box{
height: 200px;
background-color: #ddd;
text-align: center;
}
.inner_box{
display: inline-block;
width: 90%;
height: 50px;
background-color: #f00;
vertical-align: middle;
}
.box:after{
content: '';
display: inline-block;
height: 100%;
vertical-align: middle;
}
</style>
</head>
<body>
<div class="box">
<div class="inner_box"></div>
</div>
</body>
</html>
网友评论