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

直接上代码:很简单 <div style="width: 200px;height: 200px;margin: 0 auto;background: #007AFF;">左右居中1</div> <div style="width: 200px;height: 200px;margin: 0 auto...

直接上代码:很简单

<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;">

attachments-2020-06-uGEoet6m5eef810248021.png

  • 发表于 2020-06-21 23:47
  • 阅读 ( 639 )

你可能感兴趣的文章

相关问题

0 条评论

请先 登录 后评论
admin
admin

651 篇文章

作家榜 »

  1. admin 651 文章
  2. 粪斗 185 文章
  3. 王凯 92 文章
  4. 廖雪 78 文章
  5. 牟雪峰 12 文章
  6. 李沁雪 9 文章
  7. 全易 2 文章
  8. Stevengring 0 文章