问答详情
源自:8-2 慕课网-绝对定位整页布局演示

视频中老师说绝对定位元素受限于父级元素是什么意思??

视频中老师说绝对定位元素受限于父级元素是什么意思??

提问者:qq_花裤衩_2 2017-11-30 11:19

个回答

  • 兼容并包
    2017-12-07 22:13:27

    http://img1.mukewang.com/5a294c7e000164c305540453.jpg

    <!doctype html>

    <html>

    <head>

    <meta charset="utf-8">

    <title>绝对定位受父级元素影响</title>

    <style>

    .box1 {

    width:400px;

    height:400px;

    background-color:red;

    text-align:right;

    position: relative;

    }

    .box2 {

    width:200px;

    height:200px;

    background-color:green;

        position: absolute;

    left: 0; 

    top: 0;

    }

    </style>

    </head>

    <body>

    <div class="box1">box1

      <div class="box2">box2块的绝对定位受box1块的影响(这就叫绝对定位受父级影响,我这么说你能理解不)</div>

    </div>

    </body>

    </html>