css 居中布局方案
position(transform css3 有些浏览器不兼容) <article id="one"> <section id="section"></section> </article> <style> #one { position: relative; //此处不设置的话 会一直往上找 找到body width: 300px; height: 300px; background: lightskyblue; } #section { position: absolute; left: 50%; top: 50%; width: 100px; height: 100px; background: aliceblue; transform: translate(-50%, -50%); } </style> 2.margin-top(需要知道具体尺寸计算) <article id="one"> <section id="section"></section> </article> <style> #one { position: relative; width: 300px; height: 300px; background: lightskyblue; } #section { position: absolute; left: 50%; top: 50%; width: