首页 > 其他 > 详细

定位(position)

时间:2016-10-21 02:00:25      阅读:295      评论:0      收藏:0      [点我收藏+]

<!DOCTYPE html>

<html>

<head>

<title></title>

</head>

<body>

<!-- position: relative:相对定位(相对于自身位置) -->

<div style="width: 400px; height: 400px; background-color: #ff6699; position: relative;top: -50px; left: -50px;">

</div>


<!--position: absolute:绝对定位(相对于具有position属性父级元素移动,如果父级元素没有position属性就相对于body移动)  -->

<div style="width: 800px; height: 800px; background-color: #ff0000;position: absolute;">

<div style="width:500px;height: 500px;background-color: #00ff00; ">

<div style="width: 200px;height: 200px;background-color: #0000ff;position: absolute;top: 150px;left: 150px;">

</div>

</div>

</div>

</body>

</html>

技术分享


本文出自 “12145704” 博客,请务必保留此出处http://12155704.blog.51cto.com/12145704/1863872

定位(position)

原文:http://12155704.blog.51cto.com/12145704/1863872

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