当前位置:网站首页>五种定位——粘性定位
五种定位——粘性定位
2022-08-10 00:03:00 【青山酒温如南】
五种定位:
position:static;
position:relative;
position:absolute;
position:fixed;
position:sticky;
static:静态定位,常规定位。此时top,bottom,left,right和z-index属性无效。
relative:相对定位。不改变页面布局下调整元素位置。
absolute:绝对定位。将元素移出常规文本流(即不为元素预留空间),相对于最近的非static定位的祖先元素偏移,可以设置外边距且不会与其他边距合并。通常使用时注意子绝父相。
父元素{
position:relative;
}
子元素{
position:absolute;
top:10px;
left:50px;
}
fixed:视口定位。将元素移出常规文本流(即不为元素预留空间),使元素相对于屏幕视口的位置来指定元素位置。fixed
属性会创建新的层叠上下文。当元素祖先的 transform
, perspective
或 filter
属性非 none
时,容器由视口改为该祖先。
sticky:粘性定位。元素根据常规文本流定位,相对他的最近滚动祖先(nearest scrolling ancestor)和最近块级祖先,包括table-related元素进行偏移,且偏移不会影响其他元素。且也会创建新的层叠上下文。
层叠上下文:可以用z-index控制上下的。原理是对HTML元素构建一个三维思想,由屏幕引申到眼睛的一条Z轴。
边栏推荐
- The technical aspects of the byte have been passed, and the salary has been negotiated for 20K*13, but the result is still being brushed. I asked the HR why...
- 游泳馆系统次卡的设置有哪些细节?
- R语言使用glm函数构建逻辑回归模型(logistic)、使用subgroupAnalysis函数进行亚组分析并可视化森林图
- R语言使用glm函数构建logistic回归模型,使用forestmodel包的forest_model函数可视化逻辑回归模型对应的森林图
- [SUCTF 2019]CheckIn (.htaccess和.user.ini)
- 分形网络(FractalNet)----学习笔记
- Moonbeam网络维护模式(Maintenance Mode)解读
- Characteristics of the (CAS:1527486-16-3TAMRA-azide-PEG3-Biotin) reaction in biotin azide!
- dlopen failed: library "libtaml.so" not found
- Redisson 分布式锁
猜你喜欢
随机推荐
assert利用蚁剑登录
Leetcode83. 删除排序链表中的重复元素
dlopen failed: library "libtaml.so" not found
Leetcode80. 删除有序数组中的重复项 II
Summary of basic operations of c language files
WPF DataGrid using data templates
03|流程控制
Redis 非关系型数据库学习(一) ---- Redis 的安装
win10重装系统后没声音怎么办?
高校就业管理系统设计与实现
宽带由20M换为100M
OSS-访问oss生成的url无法访问,直接下载问题
abicc 知:API compatibility report 介绍
Data storage - the C language
MATLB|And her ups and downs and finally reached the peak of life [Romantic Journey]
-red and black-
Kubernetes 60个为什么
【「收藏」Oracle 数据库安装】
什么是 PWA
深度剖析 Apache EventMesh 云原生分布式事件驱动架构