• css BFC


    BFC布局规则:

    1. 内部的Box会在垂直方向,按照从上到下的方式逐个排列。
    2. Box垂直方向的距离由margin决定。属于同一个BFC的两个相邻Box的margin会发生重叠
    3. 每个元素的margin box的左边,与包含块border box的左边相接触(对于从左往右的格式化,否则相反)。即使存在浮动也是如此
    4. BFC的区域不会与float box重叠
    5. BFC就是页面上的一个隔离的独立容器,容器里面的子元素不会影响到外面的元素。反之也如此
    6. 计算BFC的高度时,浮动元素的高度也参与计算

    元素首先需要是一个block元素,才能变成BFC;

    触发BFC的条件:

    • 根元素,body
    • float的值不为none
    • overflow不为visible;可以是hidden或auto或scroll
    • display的值设置为inline-block,flex或者inline-flex,table-cell,table-caption或者inline-table
    • position的值设置为absolute、fixed

    因此通过将其中一个元素display属性设置为inline-block,width设置为100%是比较好的解决方式;既解决了margin穿透问题,又达到与display为block一样的效果。

    与BFC对应的另外一个概念IFC(inline formatting context) 行内格式化上下文

  • 相关阅读:
    Simple Form Fading
    CResizableFormView
    User-Defined Multi-Lingual Applications
    Automatic Resizing of a FormView Based Application When the User Toggles the Control Bars On or Off
    Save Zip File in Access Database With File Encryption in C#
    continue
    break
    declare/typeset
    bg/fg/jobs
    .
  • 原文地址:https://www.cnblogs.com/zhangzs000/p/12925371.html
Copyright © 2020-2023  润新知