Html Episode 14: Absolute Positioning

Please indicate the source of the reprint: http://blog.csdn.net/zhaoyanjun6/article/details/127229909
This article comes from [Zhao Yanjun's blog]

Article directory

absolute positioning

insert image description here

example

<head>

    <style>
    
        .box1 {
    
    
            width: 100px;
            height: 100px;
            background-color: tomato;
        }

        .box2 {
    
    
            width: 120px;
            height: 100px;
            background-color: #bfa;
        }

    </style>

</head>
<body>

<div class="box1">1</div>
<div class="box2">2</div>

</body>

insert image description here
Enable absolute layout

<head>

    <style>
    
        .box1 {
    
    
            width: 100px;
            height: 100px;
            background-color: tomato;
            position: absolute;
        }

        .box2 {
    
    
            width: 120px;
            height: 100px;
            background-color: #bfa;
        }

    </style>

</head>
<body>

<div class="box1">1</div>
<div class="box2">2</div>

</body>

insert image description here

It can be seen that after box1 enables absolute positioning, box1 is separated from the document flow, and box1 is promoted to a higher level. Box2 moves up to the position of box1.

Guess you like

Origin blog.csdn.net/zhaoyanjun6/article/details/127229909