<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>自适应高度下div水平垂直居中</title>
</head>
<style>
* {
padding: 0;
margin: 0;
}
/* flex居中 */
.tith1 {
display: flex;
justify-content: center;
align-items: center;
background: red;
}
/* table居中 */
.tith2 {
text-align: center;
width: 100%;
display: table;
background: blue;
}
.tith2 > span {
display: table-cell;
vertical-align: middle;
}
</style>
<body>
<p class="tith1">
<span>123</span>
</p>
<p class="tith2">
<span>123</span>
</p>
</body>
</html>
Like (0)
Donate
微信扫一扫
支付宝扫一扫


外层有一个自适应高度的div,里面有两个div,一个高度固定300px,另一个怎么填满剩余的高度?
Previous
2021年2月22日
js数组去重(区分object、“NaN”、NaN)
Next
2021年2月23日