当前位置:网站首页>The thirteenth day of learning programming
The thirteenth day of learning programming
2022-08-11 03:21:00 【May 8 same city】
Height collapse:
The height of the parent element is generally stretched by the child element or the content. If the child element is set to float, the child element will be separated from the document flow and cannot support the height of the parent element, thusCauses the height of the parent element to be lost and the page layout is chaotic
Solution 1 to solve the height collapse:
Set the height of the parent element
This method is not recommended
The implicit attribute in the page element: Block FormattingContext is the block formatting context, referred to as BFC
When the BFC of the element is turned on, the element will become an independent layout area, and will not affect the layout of the outside elements
BFC is understood as a closed big box, elements inside the box will not affect the outside.
After BFC is enabled, the element will have the following characteristics:
1. The vertical margin of the parent element will not overlap with the child element (to solve the problem of overlapping parent and child margins)
2. The element with BFC enabled does notIt will be covered by floating elements
3. Elements with BFC enabled can contain floating child elements (can solve height collapse)
How to enable BFC of elements
1. Set element floating (not recommended)
- Using this method to open, although the parent element can be stretched, it will cause the width of the parent element to be lost
And using this method will also cause the lower element to move up, which cannot solve the problem
2. SettingElement is inline-block (not recommended) - It can solve the problem of height loss, but it will cause width loss, and there will be a three-pixel blank, which is not recommended
3. Set the overflow of the element to a non-visible value
The side effects are relatively small, it is recommended to use
4. Set the absolute positioning of the element (not learned yet) The
element will also be separated from the document flow. Although it can stretch the parent element, it will cause the width of the parent element to be lost.
and useThis method will also cause the element below to move up, which cannot solve the problem.
Recommended method: Setting overflow to hidden is the way to enable BFC with the least side effect.
Sometimes we want to clear the influence of other floating elements on the current element, then we can use clear to complete the function
clear can be used to clear the influence of other floating elements on the current element
Optional value:
none, the default value, does not clear the floating
left, clears the influence of the left floating element on the current element
right, clears the influence of the right floating element on the current element
both, clears the floating elements on both sidesInfluence on the current element
Clear the float of the element that affects him the most
Solution 3 for height collapse:
You can directly add a blank block element at the end of the height collapsed parent element,
Since this block element is not floating, it can stretch the height of the parent element,
and then clear the floating, so that the height of the parent element can be stretched through this blank block element,
> Basically no side effects
Although this method can solve the problem, it will add redundant structure to the page.
When the element is set to float, it will be completely separated from the document flow, and some characteristics of the element will also be changed.
The characteristics of leaving the document flow
Block element:
1: The block element no longer occupies a single line of the page.
2: The width and height of the block element are stretched by the content
Inline elements:
1: The floated inline elements are more like inline block elements, because multiple lines can be displayed, and the default width is the content of the contentWidth
Summary: When the element is set to float and is separated from the document flow, there is no need to distinguish between block and inline
边栏推荐
- (Nips-2015) Spatial Transformer Network
- 论文精度 —— 2017 CVPR《High-Resolution Image Inpainting using Multi-Scale Neural Patch Synthesis》
- UNI-APP_iphone苹果手机底部安全区域
- C语言之自定义类型------结构体
- Add support for Textbundle
- AI+医疗:使用神经网络进行医学影像识别分析
- 代码 Revert 后再次 Merge 会丢失的问题,已解决
- 作业8.10 TFTP协议 下载功能
- 树莓派入门(5)系统备份
- ES6 advanced string processing new features
猜你喜欢
Multi-merchant mall system function disassembly 26 lectures - platform-side distribution settings
leetcode: 358. Reorder strings at K distance intervals
Getting Started with Raspberry Pi (5) System Backup
Idea (优选)cherry-pick操作
图解LeetCode——640. 求解方程(难度:中等)
Environment configuration of ESP32 (arduino arduino2.0 VScode platform which is easy to use?)
Summary of debugging skills
The practice of alibaba data synchronization component canal
flink The object probably contains or references non serializable fields.
flink The object probably contains or references non serializable fields.
随机推荐
分布式和集群的区别和联系
df和df -lh的意思
程序化交易的策略类型可以分为哪几种?
"Beijing-Taiwan high-speed rail" debuted on Baidu map, can it really be built in 2035?
A practice arrangement about map GIS (below) GIS practice of Redis
rac备库双节点查询到的表最后更新时间不一致
flink The object probably contains or references non serializable fields.
求和、计数的窗口函数应用
QueryDet:级联稀疏query加速高分辨率下的小目标检测
Multi-merchant mall system function disassembly 26 lectures - platform-side distribution settings
Paper Accuracy - 2017 CVPR "High-Resolution Image Inpainting using Multi-Scale Neural Patch Synthesis"
What problems should we pay attention to when building a programmatic trading system?
广州纸质发票再见!开住宿费电子发票即将全面取代酒店餐饮加油站发票
常用认证机制
Detailed explanation of new features of ES advanced array function syntax
大马驮2石粮食,中马驮1石粮食,两头小马驮一石粮食,要用100匹马,驮100石粮食,如何分配?
正式发布丨VS Code 1.70
MSP430如何给板子下载程序?(IAR MSPFET CCS)
Add support for Textbundle
音视频开发,为什么要学习FFmpeg?应该怎么入手FFmpeg学习?