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

div水平和垂直居中显示

时间:2017-05-14 12:11:23      阅读:111      评论:0      收藏:0      [点我收藏+]

标签:ext   显示   top   div   尺寸   height   idt   bottom   auto   

.div1{

    width: 100px;
    height: 100px;
    border: 4px solid red;
    position: absolute;

    text-align: center;

    left:0;
    right:0;
    top: 0;
    bottom: 0;
    margin: auto;
    /*50%为自身尺寸的一半*/
}

效果如图

技术分享

div水平和垂直居中显示

标签:ext   显示   top   div   尺寸   height   idt   bottom   auto   

原文地址:http://www.cnblogs.com/loveBetty/p/6851797.html

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