0
点赞
收藏
分享

微信扫一扫

嵌套div的margin-top无效问题解决

微言记 2022-04-23 阅读 61
 <style>
        * {
            margin: 0;
            padding: 0;
        }
        
        .father {
            position: relative;
            width: 200px;
            height: 200px;
            background-color: pink;
            /* margin: 100px; */
            /* overflow: hidden; */
        }
        
        .son {
            width: 100px;
            height: 100px;
            background-color: antiquewhite;
            margin-left: 45px;
            margin-top: 20px;
        }
    </style>
 <div class="father">
        <div class="son"></div>
    </div>

 已经对子盒子设置了margin-top但是没有下来

设置的margin-top也没有被划去,这时怎么回事呢?

 

给父盒子添加overflow:hidden

 

 

举报

相关推荐

0 条评论