当前位置:网站首页>相对定位和绝对定位
相对定位和绝对定位
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,标签位置仍安“文档流”定位,但已经“脱离文档流”
边栏推荐
- Redirection and files
- 移动端-flex项目属性
- 牛客网编程题—【WY22 Fibonacci数列】和【替换空格】详解
- ClickHouse学习(一)ClickHouse?
- ClickHouse学习(七)表查询优化
- Detailed explanation of exit interrupt
- R & D efficiency | analysis of kubernetes' core technology and Devops' landing experience
- 【剑指offer】— 详解库函数atoi以及模拟实现atoi函数
- 浅谈Servlet
- One dimensional array exercise
猜你喜欢

Day 3

实现简单的数据库查询(不完整)

Alibaba cloud Zhang Xintao: heterogeneous computing provides surging power for the digital economy

省市区三级联动(简单又完美)

365 day challenge leetcode1000 question - distance between bus stops on day 038 + time-based key value storage + array closest to the target value after transforming the array and + maximum value at t
![[event preview] cloud digital factory and digital transformation and innovation forum for small and medium-sized enterprises](/img/6f/f7c5d605ea9b7b9e7c49ac716492ef.jpg)
[event preview] cloud digital factory and digital transformation and innovation forum for small and medium-sized enterprises

R & D efficiency | analysis of kubernetes' core technology and Devops' landing experience

【C语言系列】— 把同学弄糊涂的 “常量” 与 “变量”

虚拟增强与现实第二篇 (我是一只火鸟)

牛客网编程题—【WY22 Fibonacci数列】和【替换空格】详解
随机推荐
link与@import导入外部样式的区别
365 day challenge leetcode 1000 questions - day 039 full binary tree inserter + find peak II + snapshot array
·来一篇编程之路的自我介绍吧·
用threejs 技术做游戏跑酷
Terminal shell common commands
Cryengine Technology
Day 3
167. Sum of two numbers II - enter an ordered array
With cloud simulation platform, Shichuang technology supports the upgrading of "China smart manufacturing"
Time complexity and space complexity
Camunda 1、Camunda工作流-介绍
小程序中的DOM对象元素块动态排序
抢先预约 | 阿里云无影云应用线上发布会预约开启
省市区三级联动(简单又完美)
移动端-flex项目属性
Basic use of redis
Longest string without duplicate characters
抽象类与接口
数组学习之入门简单题 两数之和
Playwright实战案例之爬取js加密数据