css设置div盒子上下左右都居中

直接上代码:很简单
<div style="width: 200px;height: 200px;margin: 0 auto;background: #007AFF;">左右居中1</div>
<div style="width: 200px;height: 200px;margin: 0 auto;background: red;position: absolute;left: 0;right: 0;">左右居中2</div>
<div style="width: 200px;height: 200px;margin: auto 0;background: green;position: absolute;top: 0;bottom: 0;">上下居中</div>
<div style="width: 200px;height: 200px;margin: auto auto;background: green;position: absolute;top: 0;bottom: 0;left: 0;right: 0;">上下左右居中</div>

css设置div盒子上下左右都居中

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:http://www.duanlonglong.com/qdjy/170.html