当前位置:网站首页>相对定位和绝对定位
相对定位和绝对定位
2022-07-29 05:10:00 【Try your best】
相对定位和绝对定位
除了基于“文档流”的定位,CSS还定义了标签的其他定位方式,CSS使用position属性指定标签的定位方式
position的值
static,默认值,即使用基于“文档流”的定位
relative,相对定位,即在“文档流”的基础上,结合left和top属性,相对定位
absolute,绝对定位,即脱离“文档流”,并基于它的“包含框”,使用left和top属性来定位
fixed,固定定位,即特殊的绝对定位,即它的“包含框”为浏览器
position:relative;(相对定位)
注意:
相对与原来的位置,使用left,right进行偏移
原来的位置对于后继元素的定位(float)依然有效
对于使用float的元素,realative也同样起作用
position:absolute;(绝对定位)
注意:
绝对定位脱离了”文档流“,
使用绝对定位时,注意找准”包含框“,即包含该标签,并且距它最近的,position不等于static的标签
如果没有,那么将以浏览器左上角为准来定位
特别
只定义position:absolute;没设置left和top,标签位置仍安“文档流”定位,但已经“脱离文档流”
边栏推荐
- Talking about Servlet
- 【C语言系列】— 一道递归小题目
- 文件结尾
- Three handshakes and four waves for the interview summary
- [C language series] - print prime numbers between 100 and 200
- 【剑指offer】— 详解库函数atoi以及模拟实现atoi函数
- 刷题狂魔—LeetCode之剑指offer58 - II. 左旋转字符串 详解
- 牛客网编程题—【WY22 Fibonacci数列】和【替换空格】详解
- One dimensional array exercise
- ClickHouse学习(二)ClickHouse单机安装
猜你喜欢
ClickHouse学习(七)表查询优化
shell基本操作(下)
R & D efficiency | analysis of kubernetes' core technology and Devops' landing experience
C语言 一级指针
Day 1
Complete ecological map of R & D Efficiency & selection of Devops tools
Live broadcast preview | how to improve enterprise immunity through "intelligent edge security"?
Day 1
抢先预约 | 阿里云无影云应用线上发布会预约开启
Best practices for elastic computing in the game industry
随机推荐
eggjs 创建应用知识点
【C语言系列】—深度解剖数据在内存中的存储(一) 暑假开篇
公众号不支持markdown格式文件编写怎么办?
C language first level pointer
Cryengine3 debugging shader method
Day 3
Basic principle of recursion
EXIT中断详解
Day 3
Day 1
Bubble sort c language
第三课threejs全景预览房间案例
整数溢出和打印
Basic use of redis
一维数组练习
Application of Huffman tree and Huffman coding in file compression
Integer overflow and printing
数组学习之入门简单题 两数之和
Cryengine Technology
167. Sum of two numbers II - enter an ordered array