子元素absolute定位时父元素有无relative的区别

原文:https://blog.csdn.net/Efficiency9/article/details/72630347

.father{
            width: 200px;
            height: 200px;
            background-color: red;
            margin:0 auto;
            /*position: relative;*/
        } .son{
            width: 50px;
            height: 50px;
            background-color: yellow;
            position: absolute;
            top: 10px;
            left: 10px;
        }

 父元素没有relative:

子元素absolute定位时父元素有无relative的区别_第1张图片

 父元素有relative:

子元素absolute定位时父元素有无relative的区别_第2张图片

你可能感兴趣的:(html,css,js)