zoukankan      html  css  js  c++  java
  • margin-top 为什么会影响父元素的 margin-top

     1.原因:

     In this specification, the expression collapsing margins means that adjoining margins (no non-empty content, padding or border areas or clearance separate them) of two or more boxes (which may be next to one another or nested) combine to form a single margin.

    ----所有毗邻的两个或更多盒元素的margin将会合并为一个margin共享之。毗邻的定义为:同级或者嵌套的盒元素,并且它们之间没有非空内容、 Padding或Border分隔。

    2.解决方法:

      1、修改父元素的高度,增加padding-top样式模拟(padding-top:1px;常用)
      2、为父元素添加overflow:hidden;样式即可(完美)
      3、为父元素或者子元素声明浮动(float:left;可用)
      4、为父元素添加border(border:1px solid transparent可用)
      5、为父元素或者子元素声明绝对定位

  • 相关阅读:
    gnats配置文件
    在Mac中安装python,配置python环境
    利用git bash和git gui向git远程仓库提交文件
    os模块
    django中的locale()函数
    django配置静态文件
    sso单点登录
    django get_object_or_404
    关于token
    Django的CSRF机制
  • 原文地址:https://www.cnblogs.com/zouqin/p/5473277.html
Copyright © 2011-2022 走看看