当前位置:网站首页>Understand the box model, and the basic methods of box model's frame, internal and external margins, horizontal layout, vertical layout, setting floating, and dealing with height collapse
Understand the box model, and the basic methods of box model's frame, internal and external margins, horizontal layout, vertical layout, setting floating, and dealing with height collapse
2022-07-23 09:17:00 【Dummerd】
One 、 Horizontal layout :
margin-left+ border-left + padding-left+ width +padding-right+ border-right +margin-right
Horizontal direction this 7 The sum of values must be equal to the width of its parent element content
30+5+20+100+20+5+? = 600 If there is an inequality , The browser will adjust this by itself 7 It's worth , So that the equation holds , This process is called overconstraint
How to adjust :
1、 Of the seven values , without auto, Then adjust margin-right
2、 There are three values that can be set auto margin-left width margin-right
1 individual auto
margin-left margin-right width
If there is a auto, Others are fixed values , Then the browser will adjust this auto
2 individual auto
margin-left width adjustment width
width margin-right adjustment width
margin-left margin-right Adjust the browser by half , This will center the box horizontally
3 individual auto
margin-left width margin-right adjustment width
summary :
as long as width by auto, The browser will definitely adjust widthwidth>right>left
Two 、 Vertical layout :
top+margin-top+borfer-top+padding-top+width+padding-bottom+border-bottom+margin-bottom+bottom= The height of the content block containing the block
Adjustment is the same as horizontal layout
<style>
.div1 {
width: 300px;
height: 300px;
background-color: coral;
position: relative;
}
.son1 {
width: 50px;
height: 50px;
background-color: cornflowerblue;
position: absolute;
left: 0;
right: 0;
/* margin: 0 auto; */
top: 0;
bottom: 0;
margin: auto;
}
</style>
3、 ... and 、 float :
Optional value
float: Optional value
:none The default value is , No floating
left Float left
right Floating to the right
The characteristics of floating :1. The element breaks away from the standard document flow , Move up the following elements
Realize text surround picture display , So floating elements will overwrite the elements of the standard stream , But the element text content will not be overwritten
2. The floating element will not exceed the parent element
3. Setting the floating of row elements will change the properties of elements , Become a block element
Four 、 Remove the floating :
clear :
Optional value :none Default , Unclear floating
left Clear left float
right Clear right float
both Clear the side that has the greatest impact on it -->
A high degree of collapse :
What is it? ?
solve 1. Set the height of the parent element , However, it is not recommended to adapt to a high level of sub elements .
solve 2. Remove the floating , It is to clear the two side floating influence of the influence element
solve 3: Turn on the parent element's BFC( Block level environment ),css Shadow attribute ,
a. The parent element floats , Itself out of the document stream , Affect the layout behind ,, No width and height , The width and height of the parent element are supported by the content by default , Not recommended
b. The parent element is set as an inline block element , No width and height , The width and height of the parent element are supported by the content by default , Not recommended
c. Parent element Settings overflow Not visible, Recommended settings hidden/auto
d. Parent element location ( I haven't learned yet )
solve 4. Add a non floating element at the end of the parent element , Clear the floating on both sides of the element ,
a. stay html Add elements directly to , Then clear the float , But this will disrupt html Structure , Not recommended
b. Add elements through pseudo classes , Set element properties and clear floats , It won't disturb html Structure , It is recommended to use and solve the problem of outer margin coincidence
边栏推荐
- Huawei applications have called the checkappupdate interface. Why is there no prompt for version update in the application
- 涅槃重生!字节大牛力荐大型分布式手册,凤凰架构让你浴火成神
- . net to develop cloud native applications, you only need to add oil to yourself
- 只有漂亮的才能点开
- Is it safe to buy shares and open an account? Will you lose money?
- 1646. 获取生成数组中的最大值递归法
- rust allow dead_code
- 视频点播中相关分辨率说明
- openresty lua-resty-balancer动态负载均衡
- 详解Vector
猜你喜欢

解析steam与创客教育课堂的统筹规划

JMeter --- JMeter installation tutorial

Mathematical modeling -- graph and network models and methods (II)

How many of the 50 classic computer network interview questions can you answer? (top)

华为应用已经调用了checkAppUpdate接口,为什么应用内不提示版本更新

万物互联时代,看IoT测试如何应对“芯”挑战

数学建模——插值拟合

一个月学透阿里整理的分布式架构笔记

差分数组操作的一些性质

C语言经典练习题(1)——“水仙花数“
随机推荐
Trigger event when input is completed
一文了解微服务低代码实现方式
UGUI源码解析——IMaterialModifier
博途PLC信号处理系列之限幅消抖滤波
The role of include in makefile
Software testing interview ideas, skills and methods to share, learn is to earn
How many points can you get on the latest UnionPay written test for test engineers?
SQL用户表的通用设计
Pytorch visualization
券商真的有保本型理财产品吗?
购买股票开户安全吗,会亏钱吗?
php获取证书编号没有serialNumberHex只有serialNumber处理方法
2302. 统计得分小于 K 的子数组数目-滑动数组-双百代码
IDM downloader free high-quality win download tool without restrictions
Transformer summary
Mathematical modeling -- graph and network models and methods (II)
【华为联机对战服务】客户端退出重连或中途进入游戏,新玩家如何补帧?
Airserver third party projection software v7.3.0 Chinese Version (airplay terminal utility)
实行自动化网络性能监控的优势
. net to develop cloud native applications, you only need to add oil to yourself