方法一(宽高不固定)
.Box{
width: 600px;
height: 400px;
position: absolute;
left: 50%;
top: 50%;
transform: translate(-50%, -50%);
}
方法二(宽高固定)
.Box{
width: 600px;
height: 400px;
position: absolute;
left: 50%;
top: 50%;
margin-top:-200px;
margin-left:-300px;
}
方法三(不定宽高)
.Box{
position: absolute;
left: 0;
top: 0;
right:0;
bottom:0;
margin:auto;
}
方法四(不定宽高)
.Box{
display:flex;
justify-content: center;
align-items: center;
}
方法五(不定宽高)
.Box{
display: table-cell;
vertical-align: middle;
text-align: center;
}
//子节点
.Box-item{
display:inline-block;
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。