当前位置:网站首页>Floating effect and characteristics
Floating effect and characteristics
2022-07-25 22:27:00 【Start】
1. What is floating ?
CSS Of Float( float ), Causes the element to move left or right , The elements around it will also rearrange .
Float( float ), Often used for images , But it's also very useful in layout .
2. The characteristics of floating
characteristic 1:
1: Floating elements are detached from the document stream , After the element leaves the document stream , No longer occupy the location of the document stream , The element below it will immediately move up
2: After the element floats , Elements will try to float to the top left or right of the page
3: Floating elements are not removed from the parent element by default
4: The floating element will not exceed its brother element , One side at most
5: If above the floating element is a block element without floating , The floating element cannot be moved up
characteristic 2:
Floating elements don't cover text , Text will automatically wrap around floating elements ,
So we can set the effect of text wrapping around the picture by floating
When the element is set to float , Will be completely detached from the document flow , Some characteristics of elements will also change
3. Break away from the characteristics of document flow
A block element :
1: Block elements no longer monopolize one line of the page
2: The width and height of the block element are spread by the content
Inline elements :
The floating inline elements are more like inline block elements , Because one line can show multiple , And the default width is the width of the content
summary : When the element is set to float , Off stream , There is no need to distinguish between blocks and lines , More like inline block elements
The following is a simple layout made of floating
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
*{
margin: 0;
padding: 0;
}
li{
list-style: none;
}
a{
text-decoration: none;
}
body{
width: 900px;
margin: 0 auto;
/* Premise fixed width */
}
header{
width: 100%;
height: 100px;
background-color: aqua;
margin-bottom: 10px;
}
.div1{
width: 300px;
height: 300px;
background-color: aquamarine;
}
.div2{
width: 300px;
height: 300px;
background-color: black;
}
.div3{
width: 300px;
height: 300px;
background-color: rgb(235, 15, 198);
}
.div1,.div2,.div3,footer{
float: left;
}
footer{
width: 100%;
height: 300px;
background-color: rgb(176, 235, 15);
margin-top: 10px;
}
</style>
</head>
<body>
<header>
</header>
<main>
<div class="div1"></div>
<div class="div2"></div>
<div class="div3"></div>
</main>
<footer>
</footer>
</body>边栏推荐
- 3day
- Call of addition, subtraction, multiplication and division of integer type only
- ML-Numpy
- ORM common requirements
- [leetcode] 502.ipo (difficult)
- (1) DDL, DML, DQL, DCL and common data types
- IPv4地址已经完全耗尽,互联网还能正常运转,NAT是最大功臣!
- Leetcode 106. construct binary tree from middle order and post order traversal sequence
- 【集训DAY15】简单计算【树状数组】【数学】
- 4day
猜你喜欢

Method of converting MAPGIS format to ArcGIS

Using simple scripts to process data in 3dslicer

Xiaobai programmer's seventh day

关于getchar和scanf的使用示例及注意点

On the difference between break and continue statements

About vscode usage+ Solutions to the problem of tab failure

IFLYTEK smart office book air e-book reader makes my work life healthier

Data governance under data platform

Fill the whole square with the float property

Wechat official account application development (I)
随机推荐
沃达德软件:智慧城市方案
Don't know mock test yet? An article to familiarize you with mock
H5 lucky scratch lottery free official account + direct operation
Compile and decompile
【集训DAY13】Internet【并查集】
Builder pattern
Fill the whole square with the float property
According to the use and configuration of data permissions in the open source framework
【集训DAY12】Minn ratio 【dfs】【最小生成树】
Share two music playing addresses
【C语法】void*浅说
xss-收集常用的代码
Short circuit effect of logical operators short circuit and short circuit or
Xiaobai programmer day 8
Five constraints and three paradigms
What is class loading? Class loading process?
Wechat applet application development competition works comprehensive development record - Jinlu cultural tourism (cloud development - Overview)
How to call the size of two numbers with a function--- Xiao Tang
[leetcode] 502.ipo (difficult)
Leetcode 106. 从中序与后序遍历序列构造二叉树