码迷,mamicode.com
首页 > 其他好文 > 详细

【技术】居中(不适用于IE7及以下版本)

时间:2015-08-28 17:18:15      阅读:102      评论:0      收藏:0      [点我收藏+]

标签:

技术分享

html部分:

<div class="p-r">
  <div class="a-c-a"></div>
</div>

css部分:

.pr{
  position: relative;
}
.a-c-a{
  position: absolute;
  width: 200px;
  left: 0;
  right: 0;
  margin-left: auto;
  margin-right: auto;
  height: 400px;
  top: 0;
  bottom: 0;
  margin-top: auto;
  margin-bottom: auto;
  border: 1px solid red;
}

简写:

.pr{
  position: relative;
}
.a-c-a{
  position: absolute;
  width: 200px;
  height: 400px;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  margin: auto;
  border: 1px solid red;
}

 

【技术】居中(不适用于IE7及以下版本)

标签:

原文地址:http://www.cnblogs.com/ybingbing_1213/p/4766834.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!