<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
        <style>
            .a{
                width: 100px;
                height: 100px;
                background: red;
                position: relative;
                top: 40px;
                left: 50px;
                padding: 30px;
            }
            .b{
                width: 50px;
                height: 50px;
                background: bisque;
                position: absolute;
            }
        </style>
    </head>
    <body>
        <div class="a">
            <div class="b"></div>
        </div>
    </body>
</html>
如果不給b標簽設(shè)定top和left。他們會有個默認的值。
top和left會以width和height為基礎(chǔ)進行定位。
【 微信掃一掃 】