当前位置:网站首页>相对定位和绝对定位
相对定位和绝对定位
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,标签位置仍安“文档流”定位,但已经“脱离文档流”
边栏推荐
- 关于局部变量
- Abstract classes and interfaces
- ·来一篇编程之路的自我介绍吧·
- Alibaba cloud Zhang Xintao: heterogeneous computing provides surging power for the digital economy
- Playwright实战案例之爬取js加密数据
- 365 day challenge leetcode 1000 questions - day 037 elements and the maximum side length of squares less than or equal to the threshold + the number of subsequences that meet the conditions
- 使用微信小程序扫码登录系统PC端web的功能
- 数组学习之入门简单题 两数之和
- 三次握手四次挥手针对面试总结
- ClickHouse学习(二)ClickHouse单机安装
猜你喜欢
Application of Huffman tree and Huffman coding in file compression
One dimensional array exercise
B - identify floating point constant problems
Pyqt5: Chapter 1, Section 1: creating a user interface using QT components - Introduction
【C语言系列】—深度解剖数据在内存中的存储(二)-浮点型
PyQt5:第一章第1节:使用Qt组件创建一个用户界面-介绍
刷题狂魔—LeetCode之剑指offer58 - II. 左旋转字符串 详解
Day 3
数据库操作 Day 6
C语言 一级指针
随机推荐
Why is Google's internal tools not suitable for you?
vim编辑器使用
Clickhouse learning (IV) SQL operation
文件结尾
Terminal shell common commands
Occt learning 003 - MFC single document project
Storage category
Day 5
The road to success in R & D efficiency of 1000 person Internet companies
重定向和文件
shell基本操作(上)
AD常用快捷键
Basic use of redis
数据库操作 Day 6
【C语言系列】— 字符串+部分转义字符详解+注释小技巧
VIM editor use
ClickHouse学习(五)集群操作
C language n queen problem
Clickhouse learning (x) monitoring operation indicators
数组学习之入门简单题 两数之和