当前位置:网站首页>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>边栏推荐
- Wechat applet application development competition works comprehensive development record - Jinlu cultural tourism (cloud development - Overview)
- 数据平台下的数据治理
- 平台架构搭建
- Xiaobai programmer the next day
- 3day
- 编译和反编译
- How to call the size of two numbers with a function--- Xiao Tang
- Math programming classification
- Multi data source switching
- internship:普通常用的工具类编写
猜你喜欢
随机推荐
Ts:typera code fragment indentation display exception (resolved) -2022.7.24
科大讯飞智能办公本Air电纸书阅读器,让我的工作生活更加健康
Recursive case -c
ORM common requirements
Perform Jieba word segmentation on the required content and output EXCEL documents according to word frequency
Based on if nesting and function call
【数据库学习】Redis 解析器&&单线程&&模型
【集训DAY13】Backpack【动态规划】【贪心】
win10搭建flutter环境踩坑日记
Usage of in in SQL DQL query
数据质量:数据治理的核心
Google analyzes how UA can be transferred to the latest version of GA4
【C语法】void*浅说
Flex layout
What is the difference between character constants and string constants?
About vscode usage+ Solutions to the problem of tab failure
QML module not found
torchvision
ML-Numpy
vim用法记录








