当前位置:网站首页>Box model (2)
Box model (2)
2022-07-25 22:27:00 【Start】
all HTML Elements can be seen as boxes , stay CSS in ,"box model" The term is used in design and layout .
CSS The box model is essentially a box , Encapsulate the surrounding HTML Elements , It includes : Margin , Frame , fill , And the actual content .
The box model allows us to place elements... In the space between other elements and the surrounding element borders .
1. Horizontal layout
horizontal direction
margin-left border-left padding-left width padding-right border-right margin-right
Browser rules The sum of the seven values in the horizontal direction must be equal to the width of the parent element content area
0 5px 50px 100px 50px 5px 0 ==500 ?
Like the above , If not equal to , The browser will adjust this by itself 7 It's worth , Let our equation hold , This process is called overconstraint
How to adjust the browser ?
1、 If 7 None of the values are set auto, Then the browser will adjust margin-right
0 5px 50px 100px 50px 5px 290px ==500
2、7 Among the values are 3 Values can be set auto margin-left width margin-right
1 individual auto, The other two values are fixed
The browser will adjust this auto
2 individual auto, other 1 Values are fixed
margin-left width adjustment width
width margin-right adjustment width
margin-left margin-right meanwhile margin-left margin-right, Each half
3 individual auto
margin-left width margin-right adjustment width
2. Shadows and fillets
box-shadow
Used to set the shadow effect of an element , It will not affect the page layout
The first value is : Horizontal offset just -> Left negative -> Right
Second value : Vertical offset just -> Next negative -> On
Third values : Blur radius The default value is 0px
Fourth values : Color The default value is the background color of the box
border-radius: ; Set the fillet effect
border-radius:50%; Set circle
3. Inline element box model
Inline element box model
content Width and height cannot be set directly , Supported by content
padding You can use the inner margin , But the vertical direction will not squeeze others , That is, it will not affect the layout of the page
border You can set the border , But the vertical direction will not squeeze others , That is, it will not affect the layout of the page
margin The outer margin can be set on the left and right , The vertical direction cannot be set
4. The problem of overlapping of outer margins
1> The problem of overlapping outer margins in the vertical direction of brother elements
1、 Both are positive , Then who listens to who
2、 If both are negative , Whose absolute value is greater , Listen to who
3、 If one is positive and one is negative , Then listen to the result of adding the two
In general , The problem of overlapping outer margins of sibling elements , No additional solution is needed , It is conducive to our development
2>
A solution to the overlapping of outer margins between father and son
Scheme 1
border: 1px solid transparent;
Option two : Open the element BFC attribute
overflow: hidden;
margin-top: 100px;
5. Box size problem
By default : The size of the visible width of the box is determined by the content area , padding , The border determines
box-sizing The calculation used to set the size of the box width/height Who is it
Optional value :
content-box Content area The default value is
border-box Width and height are used to set the size of the visible box of the whole box , Including borders ,padding, Content area
边栏推荐
- Win10 set up a flutter environment to step on the pit diary
- torchvision
- Xiaobai programmer the next day
- D3.js 学习
- 【PMP学习笔记】第1章 PMP体系引论
- Playwright tutorial (I) suitable for Xiaobai
- 字符型常量和字符串常量的区别?
- Title: give a group of arrays, arranged from large to small and from small to large.
- Minor GC 和 Full GC 有什么不同呢?
- SQL中in的用法 DQL 查询
猜你喜欢

3dslicer import cone beam CT image

数据平台下的数据治理

3dslicer introduction and installation tutorial

Interpretation of the source code of all logging systems in XXL job (line by line source code interpretation)

Usage of in in SQL DQL query

Playwright tutorial (II) suitable for Xiaobai

What is partition and barrel division?

微信发卡小程序源码-自动发卡小程序源码-带流量主功能

ArcGIS10.2配置PostgreSQL9.2标准教程

关于getchar和scanf的使用示例及注意点
随机推荐
【C语法】void*浅说
Div drag effect
If it is modified according to the name of the framework module
Short circuit effect of logical operators short circuit and short circuit or
Title: give a group of arrays, arranged from large to small and from small to large.
Data governance under data platform
Wkid in ArcGIS
Don't know mock test yet? An article to familiarize you with mock
分割金条的代价
Build commercial projects based on ruoyi framework
沃达德软件:智慧城市方案
According to the use and configuration of data permissions in the open source framework
It's over. I went to work for three months and became bald
Gan, why '𠮷 𠮷'.Length== 3 ??
平台架构搭建
Randomly generate 10 (range 1~100) integers, save them to the array, and print the array in reverse order. And find the average value, the maximum value and the subscript of the maximum value, and fin
Matrix of C language
什么是类加载?类加载的过程?
MySQL - subquery - column subquery (multi row subquery)
Why is the integer type 128 to byte -128