当前位置:网站首页>五种定位——粘性定位
五种定位——粘性定位
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轴。
边栏推荐
猜你喜欢

3.4 - 编译与解释 3.5 - 编译过程 3.8 - 文法

deepstream学习笔记(三):deepstream-imagedata-multistream解析与接入适配yolov5模型测试

Leetcode82. 删除排序链表中的重复元素 II

生物素叠氮化物中的(CAS:1527486-16-3TAMRA-azide-PEG3-Biotin)反应的特点!
![MATLB|And her ups and downs and finally reached the peak of life [Romantic Journey]](/img/10/55cc34a929768d89d9ffde8a5b3419.png)
MATLB|And her ups and downs and finally reached the peak of life [Romantic Journey]

足不出户也能看星空

WPF DataGrid using data templates

365 days challenge LeetCode1000 questions - Day 052 Step by step summation to get the minimum value of positive numbers Greedy

Leetcode83. 删除排序链表中的重复元素

程序员从佩洛西窜访事件中可以学到什么?
随机推荐
What should I do if there is no sound after reinstalling the system in win10?
3.9 - 正规表达式和正规集 3.10 - 有限自动机
【CAS:41994-02-9 |Biotinyl tyramide】生物素基酪氨酰胺价格
20220808-一些想法
Fedora 36 dnf 安装ModSecurity和 OWASP 核心规则集
Spark基础【RDD单Value类型转换算子】
ASEMI整流桥GBJ1010参数,GBJ1010规格,GBJ1010封装
使用C语言实现静态链表
[C language] Address book "Static Memory Version"
算法---整数替换(Kotlin)
快速响应性智能型/智能响应性聚乙二醇纳米/还原响应型水凝胶的研究与制备
7. type( )函数——查询数据类型
Docker interview question 2--get the number of database connections and docker-compose
你有对象类,我有结构体,Go lang1.18入门精炼教程,由白丁入鸿儒,go lang结构体(struct)的使用EP06
Interlay集成至Moonbeam,为网络带来interBTC和INTR
openEuler 知:abi 检测
数据的存储——C语言
Leetcode79. 单词搜索
Fury:一个基于JIT动态编译的高性能多语言原生序列化框架
Tensor flow 踩坑记