css中的position属性

来源:互联网 发布:乔丹生涯总数据 编辑:程序博客网 时间:2024/06/05 07:55

position默认值:static

fixed:生成绝对定位的元素,相对于浏览器窗口进行定位。

relative:生成相对定位的元素,相对于其正常位置进行定位。

absolute:生成绝对定位的元素,相对于static 定位以外的第一个父元素进行定位。

例如:

<body>

<div style="position:relative" calss="parent">

<div style="position:absolute" class="child">hello</div>

</div>

</body>

child根据parent的位置进行定位。

<body>

<div calss="parent">

<div style="position:absolute" class="child">hello</div>

</div>

</body>

child根据窗口位置进行定位。

0 0