首页 > 其他 > 详细

absolute vs fixed

时间:2014-01-16 00:12:22      阅读:329      评论:0      收藏:0      [点我收藏+]
bubuko.com,布布扣
 1 <!DOCTYPE html>
 2 <html>
 3 <head>
 4 <title>absolute和fixed的区别</title>
 5 <style type="text/css">
 6 body{color:#fff;}
 7 #html{ position:relative;width:778px; height:1000px; border:1px solid #0000FF;}
 8 #fixed,#absolute{width:200px; height:200px; background:#FF0000;}
 9 #fixed{position:fixed; top:50px; left:50px;}
10 #absolute{position:absolute; top:50px; left:450px;}
11 </style>
12 </head>
13 <body>
14 <div id="fixed">我在屏幕的位置不会改变</div>
15 <div id="html">
16 <div id="absolute">我会随屏幕滚动</div>
17 </div>
18 </body>
19 </html>
bubuko.com,布布扣

 

Fixed 相对于浏览器, Absolute相对于父元素。

absolute vs fixed

原文:http://www.cnblogs.com/daishuguang/p/3516831.html

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