定位

2019-06-20  本文已影响0人  fly_198e

定位:

定位的类型:

静态定位:
相对定位:
    <div class="box box1">1</div>
    <div class="box box2">2</div>
    <div class="box box3">3</div>
    <div class="box box4">4</div>
    <style>
        .box{
            height: 80px;
            width: 80px;
            border: 3px solid ;
        }
        .box2{
            position: relative;
            left: 80px;
        }
        .box3{
            position: relative;
            left: 160px;
        }
    </style>
<!--相对定位--!>
绝对定位:
固定定位:
粘性定位:

position:sticky;粘性定位是相对定位和固定定位的混合。元素在跨越特定阈值前为相对定位,之后为固定定位。兼容性较差,一般该效果使用js来编写。

z-index:

        .box1{
            position: sticky;
            border: 3px solid;
            height: 90px;
            width: 90px;
            background: blue;
            z-index: 50;
        }
        .box5{
            border: 3px solid;
            height: 90px;
            width: 90px;
            background: green;
            z-index: 20;
        }
上一篇下一篇

猜你喜欢

热点阅读