首页 > 其他 > 详细

绝对居中

时间:2015-10-15 22:03:52      阅读:274      评论:0      收藏:0      [点我收藏+]

<!DOCTYPE html>
<html>
<head>
<title> new document </title>
<meta name="author" content="胡超" />
<meta charset="utf-8"/>
<style type="text/css">

#a2{
position:absolute; /*:绝对定位元素不在普通内容流中渲染,因此margin:auto可以使内容在通过top: 0; left: 0; bottom: 0;right: 0;设置的边界内垂直居中。父元素一般为body或者声明为position:relative;的容器。无需知道被垂直居中元素的高和宽。*/
top:0;
right:0;
left:0;
bottom:0;
margin: auto;
width:290px;
height:121px;
border:1px solid red;
}
#a1{
width:500px;
height:500px;
border:1px solid red;
position:relative;
}

</style>
</head>

<body>

<div id="a1">
<div id="a2">

</div>
</div>

</body>
</html>

绝对居中

原文:http://www.cnblogs.com/12606huchao/p/4883521.html

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