您的位置:首页 > Web前端 > CSS

css position 属性 (absolute 和fixed 区别)

2015-06-03 00:20 537 查看
在css3中,position的属性值有:inherit, static, relative ,absolute, fixed.

inherit 是继承父元素的position属性值,IE不支持。

static 默认值,元素出现在正常的流中,忽略 (TRBL)和z-index的值。请参照下面的例子,div1由于position的值为static,所以top,left 没有起作用.

<!Doctype html>
<meta charset="utf-8">
<head>
<title>test position static</title>
<style type="text/css">
.divPos{
position:fixed;
left:50px;
top:50px;
}
.div1{
height:1000px;
}
</style>

</head>
<body>
<div class="divPos">
The position of this div is fixed.And this div will be always here.
</div>
<div class="div1"></div>
</body>


View Code
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: