定位

2018-07-10  本文已影响0人  WANGLIN_HZ
固定定位
<!DOCTYPE html>
<html>
<head>
    <title>固定定位</title>
    <style type="text/css">
        .box1{
            width: 50px;
            height: 50px;
            background-color: red

        }
        .box2{
            width: 80px;
            height: 80px;
            background-color: rgb(177,199,210);
            position: fixed;
            left: 0px;
            top: 0px;
        }
        .box3{
            width: 100px;
            height: 100px;
            background-color: rgb(210,219,222);
        }
        .box4{
            width: 200px;
            height: 200px;
            background-color: yellow;
        }
    </style>
</head>
<body>
    <div class="box1">
        <div class="box2"></div>
    </div>
    
    <div class="box3"></div>
    <div class="box4"></div>
</body>
</html>

相对定位
<!DOCTYPE html>
<html>
<head>
    <title>相对定位</title>
    <style type="text/css">
        .box{
            width: 200px;
            height: 200px;
            background-color: red;

        }
        .box2{
            width: 200px;
            height: 200px;
            background-color: yellow;
            /*margin-left: 200px;*/
            /*margin-top: 200px;*/
            position: relative;
            left: 100px;

        }
        .box3{
            width: 200px;
            height: 200px;
            background-color: rgb(122,133,144);
        }
    </style>
</head>
<body>
    <div class="box"></div>
    <div class="box2"></div>
    <div class="box3"></div>
</body>
</html>

绝对定位
上一篇下一篇

猜你喜欢

热点阅读