<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>实现元素垂直居中</title>
<style>
.box{
background-color: pink;
overflow: hidden;
margin-bottom: 30px;
}
.text{
background-color: #aaa;
margin: 100px auto;
}
.box2 input{
margin: 30px 0;
}
.box3 a{
line-height: 100px;
}
.box4{
height: 500px;
position: relative;
}
.box4 span{
display: inline-block;
width: 200px;
height: 200px;
background-color: #eee;
position: absolute;
top: 50%;
margin-top: -100px;
}
</style>
</head>
<body>
<b>方法一:</b>针对块级元素在块级元素里垂直居中比较容易,父级元素不设置高度,设置overflow: hidden;(记得!!&
CSS如何将元素垂直居中方法锦集
最新推荐文章于 2022-03-08 10:33:35 发布