CSS 的position属性

CSS的position属性的关键字分别是static、relative、absolute、fixed、sticky。


static

static根据文档的正常流进行定位。对top、right、bottom、left、z-index属性没有影响。这是默认值。

如图所示:

relative

relative根据文档的正常流进行定位,根据top、right、bottom、left的值相对于自身进行偏移。

效果图

HTML

<!DOCTYPE html>

<html>

    <head>

            <meta charset="utf-8">

            <title>relative</title>

            <link href="relative.css" rel="stylesheet" type="text/css" >

    </head>

    <body>

            <div class="box" id="one">One</div>

            <div class="box" id="two">Two</div>

            <div class="box" id="three">Three</div>

            <div class="box" id="four">Four</div>

 

        </body>

</html>

 

猜你喜欢

转载自www.cnblogs.com/LLLL-MM/p/9856974.html