子元素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;
        }
<div id="father">
    <div class="son"></div>
</div>

 父元素沒有relative:

 父元素有relative:

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章