浮动元素的水平居中

直接看代码,完美兼容所有浏览器:

<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style type="text/css">
* {margin:0;padding:0;}
div {width:600px; height:300px;background:#ccc; margin:50px auto 0;text-align:center;font-size:0;}
p {width:100px;height:100px;background:#fff;border:1px solid red;display:inline-block;*display:inline;zoom:1;font-size:12px;margin:10px 10px 0 0;}
</style>
</head>
<body>
<div>  
    <p>p1</p>
    <p>p2</p>
    <p>p3</p>
    <p>p4</p>
    <p style="margin-right:0;">p5</p>
</div>
</body>
</html>
原文地址:https://www.cnblogs.com/fengyuqing/p/3363229.html