当前位置:网站首页>What is float?What is document flow?Several ways and principles of clearing floats?What is BFC, how to trigger BFC, the role of BFC
What is float?What is document flow?Several ways and principles of clearing floats?What is BFC, how to trigger BFC, the role of BFC
2022-07-31 07:02:00 【Fire orchid】
float
Out of standard document flow, float is the positioning in CSS styleAttribute, used to set the floating layout of label objects (such as:
Standard document flow
- Definition: Content is written from top to bottom, left to right.When the content or position in front changes, the content behind will also change.
- HTML is a document flow of tags, and the location of the content on the web page is related to the order in which we write it.
Classification of elements
Standard document flow divides HTML elements into three types:
1. Inline elements: inline.
2. Block-level elements: block.
3. Inline block element: inline-block.
Difference
Inline element:
- Arranges side by side with other inline elements.
- Cannot set width and height.The default width and height is the height of the content.
- Block-level elements are on a line of their own.
- You can set the width and height.The default paragraph is 100%, and the default height is the height of the content.
BFC
(Block-level formatting context)em>
, is an independent rendering area, let in BFC The inner element is isolated from the outer element, so that the positioning of the inner and outer elements will notinterdependent.Understanding: BFC belongs to a normal flow, which is equivalent to an independent rendering area. BFC is regarded as an attribute of an element. When an element has the BFC attribute, the element canThink of it as an isolated, independent container.Elements inside the container do not affect elements outside the container.
Rules:
- The inner Boxes will be vertically oriented, one by oneplace.
- The vertical distance of the Box is determined by the margin.The margins of two adjacent Boxes belonging to the same BFC will overlap (set according to the maximum margin value)
- The left side of the margin box of each element, with theThe left side of the block border box touches
- The area of the BFC will not overlap the float box.
- BFC is an isolated independent container on the page.Child elements inside the container do not affect elements outside.
- When calculating the height of BFC, floating elements also participate in the calculation
Characteristics and functions of BFC
1, can avoid overlapping margins
2. Clear floating
3. Prevent elements from being covered by floating elements
(Which elements or attributes can trigger BFC)Several ways to clear the float:
- root element
- position: absolute/fixed
- display: inline-block / table
- float !== none
- ovevflow !== visible
边栏推荐
猜你喜欢
随机推荐
银河麒麟服务器v10 sp1安装.net6
国际站卖家大促攻略,只需要做好这几件事
三本毕业,中途转行软件测试,顶着这些光环从月薪7k干到20k+,感觉还不错
fdisk分区,gdisk添加磁盘,parted进行磁盘分区,parted新增分区,临时挂载和永久挂载
frp内网穿透服务
Unity导入我的世界模型,简单图解教程(包括调整材质贴图和光照和添加碰撞)
Skywalking安装部署
VNC 启动脚本
定义一个生成器函数,用代码写一个和range函数功能相同的函数,re模块中函数的使用
选择排序法
读写文件,异常,模块和包
第一次实践——计算器
Oracle入门 12 - Linux 磁盘分区及LVM实战
网盘程序 ZFile安装
定义一个类,super的使用,私有属性
(border-box)盒子模型w3c、IE的区别
青龙面板从零搭建教程
成员内部类使用方式(工作)
cenos版本查询,及离线安装zip和unzip
防抖和节流