如何居中一个浮动元素

设置容器的浮动方式为相对定位,然后确定容器的宽高,比如宽500 高 300 的层,然后设置层的外边距。 

div{Width:500px;height:300px;Margin: -150px 0 0-250px;position:relative;left:50%;top:50%;}

原文地址:https://www.cnblogs.com/qingxuan/p/3275080.html