当前位置:网站首页>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 .
边栏推荐
- AQUANEE将在近期登陆Gate以及BitMart,低位布局的良机
- beef-xss安装与使用
- 页面布局中元素定位的几种方式
- [网鼎杯 2020 朱雀组]Nmap 1两种解法
- Application of store Redux in project
- 维持登录,路由跳转
- What are the traversal methods of arrays in JS
- NFT新范式,OKALEIDO创新NFT聚合交易生态
- Program environment and preprocessing (Part 2): define, undef, command line compilation, conditional compilation, file inclusion (super full collation, recommended collection!!!
- JS中原型及原型链
猜你喜欢

M-DAO 7大赋能方案,助力DAO生态走向模式与标准化

「PHP基础知识」字符串型(string)的使用

Differences among apply, call, and bind in JS

Configure the route and go to the login home page to send the request

布局的搭建及天气预报的显示
![[NPUCTF2020]ReadlezPHP 1](/img/d9/590446b45f917be3f077a9ea739c20.png)
[NPUCTF2020]ReadlezPHP 1

维持登录,路由跳转

DeFi 2.0的LaaS协议Elephant,或许是你熊市下为数不多的获利手段

First knowledge of C language - string + escape character + comment

Construction of layout and display of weather forecast
随机推荐
Flask blueprint
JS==操作符的强制类型转换规定
洛谷陶陶摘苹果
[C language switch branch statement and loop statement]
DeFi 2.0的LaaS协议Elephant,或许是你熊市下为数不多的获利手段
迭代器和生成器
C language makes a small maze
一本通1353——表达式括号匹配(栈)
My first blog
权限的配置,组件传值
「PHP基础知识」PHP中的标记
What happens to the new arrow function in ES6
[网鼎杯 2020 青龙组]AreUSerialz(BUUCTF)
eval与assert执行一句话木马
Package JWT
一本通顺序结构程序设计题解(第一章)
JS中for...of和for...in的区别
弹性盒/伸缩盒(flex)的使用
思考一些文件的作用
Graph-node部署及测试