首页 > 其他 > 详细

设置div中的div居中显示

时间:2016-10-13 14:50:11      阅读:112      评论:0      收藏:0      [点我收藏+]

 

设置div中的div居中显示

方法一、

 

<div class=big>
    
    <div class=small>box1</div>
 
 </div>

style样式:
.big{
  height:200px;
  width:200px;
  border:black solid 1px;
  position:absolute;
  left:150px;
  

}
.small{
  height:100px;
  width:100px;
  background-color:green;
  position:relative;
  left:100px;
  top:100px;
  margin-top:-50px;
  margin-left:-50px;
  border:black solid 1px;
}

方法二、

 

div class=big2>
    
    <div class=small2>box3</div>
 
 </div>


.big2{
  height:200px;
  width:200px;
  border:black solid 1px;
  text-align:center;

}
.small2{
  height:100px;
  width:100px;
  background-color:green;
  margin:50px auto; //外面的div高度的一半
  border:black solid 1px;
}

 

设置div中的div居中显示

原文:http://www.cnblogs.com/keyi/p/5956115.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!