当前位置:网站首页>Several ways of element positioning in page layout
Several ways of element positioning in page layout
2022-07-27 05:42:00 【Real code slag】
List of articles
Element localization (position)
Positioning is a more advanced layout method . Through positioning, elements can be placed anywhere in the page .
position Property has five values :
- static ------ The default value is
- relative---- Relative positioning
- absolute -- Absolute positioning
- fixed ------- Fixed position
- sticky ------ Sticky positioning
Offset (offset), There are four attributes :top、bottom、left、right.
top The bigger the value is. , The more the positioning element moves down ;bottom The bigger it is , The more positioning elements move up .left = - bottom
left The bigger the value is. , The more the positioning element moves to the right ;right The bigger it is , The more positioning elements move to the left .left = - right
1、 Relative positioning
When the element of position Property value set to relative Open relative positioning when .
characteristic :
- No offset is set (offset) when , Elements do not change .
- Relative positioning refers to positioning relative to the original position of the element .
- Relative positioning raises the level of elements .
- Relative positioning doesn't take elements out of the document stream , Will not change Element properties ( Inline elements 、 A block element ).

Relative positioning
Sticky positioning
When the element of position Property value set to sticky Open sticky positioning . Viscous positioning is a kind of relative positioning , The difference is that the element can be fixed in a certain position .
2、 Absolute positioning
When the element of position Property value set to absolute Turn on absolute positioning .
characteristic :
- When absolute positioning is turned on , If you don't set the offset , The position of the element will not change .
- The element is detached from the document stream .
- Will change the properties of the elements — Inline elements become blocks , The content of the block will be expanded by the content .
- Absolute positioning raises the element to a higher level .
- Absolute positioning elements are positioned relative to their containing blocks .
Containing block :
- Under normal circumstances , The containing block is the nearest ancestor block element to the current element .
- In the case of absolute positioning , The nearest ancestor block element that opens the location (html Root element 、 Initial inclusion block ).
Fixed position
When the element of position Property value set to fixed Open the fixed positioning . Fixed positioning is an absolute positioning , The difference is that you always refer to the browser viewport for positioning . Fixed positioned elements will not move with the scroll bar .
summary
In general work , Relative positioning and absolute positioning are mostly used , The other two compatibility have limitations .
边栏推荐
猜你喜欢
随机推荐
GameFi如何破圈,AQUANEE靠真正“P2E”展现风采
M-DAO 7大赋能方案,助力DAO生态走向模式与标准化
Gallerycms download, installation and configuration
云E办项目之部门管理
map结构
SeekTiger即将上线STI聚变Mining功能,获取OKA通证
First knowledge of C language - string + escape character + comment
「PHP基础知识」字符串型(string)的使用
JS==操作符的强制类型转换规定
NFT新的契机,多媒体NFT聚合平台OKALEIDO即将上线
「PHP基础知识」使用echo语句输出信息
进制的特性
JS中数组的遍历方法有哪些
[MRCTF2020]Ezpop 1
C language string introduction and related operation functions
First knowledge of C language -- constants and variables
What are Dom and BOM in JS
JS中如何判断一个属性是属于实例对象还是继承于构造函数
软件测试面试题(重点)
Ubuntu:安装PostgreSQL







![[极客大挑战 2019]FinalSQL 1](/img/a7/857d47639fcb38e0055a2444206b8c.png)

![[MRCTF2020]Ezpop 1](/img/c0/41873fe5864490ade403eeddc26976.png)