惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

AI
AI
TaoSecurity Blog
TaoSecurity Blog
H
Heimdal Security Blog
Help Net Security
Help Net Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Google DeepMind News
Google DeepMind News
爱范儿
爱范儿
The Cloudflare Blog
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
人人都是产品经理
人人都是产品经理
大猫的无限游戏
大猫的无限游戏
N
News | PayPal Newsroom
V2EX - 技术
V2EX - 技术
博客园 - 【当耐特】
D
Darknet – Hacking Tools, Hacker News & Cyber Security
S
Secure Thoughts
C
CERT Recently Published Vulnerability Notes
罗磊的独立博客
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
P
Privacy & Cybersecurity Law Blog
有赞技术团队
有赞技术团队
S
Schneier on Security
S
SegmentFault 最新的问题
Google Online Security Blog
Google Online Security Blog
H
Hacker News: Front Page
The Last Watchdog
The Last Watchdog
Schneier on Security
Schneier on Security
PCI Perspectives
PCI Perspectives
IT之家
IT之家
Project Zero
Project Zero
博客园 - 司徒正美
P
Privacy International News Feed
Recent Commits to openclaw:main
Recent Commits to openclaw:main
Jina AI
Jina AI
Security Latest
Security Latest
Hacker News - Newest:
Hacker News - Newest: "LLM"
腾讯CDC
C
CXSECURITY Database RSS Feed - CXSecurity.com
阮一峰的网络日志
阮一峰的网络日志
C
Check Point Blog
aimingoo的专栏
aimingoo的专栏
V
Vulnerabilities – Threatpost
W
WeLiveSecurity
NISL@THU
NISL@THU
Webroot Blog
Webroot Blog
N
Netflix TechBlog - Medium
L
Lohrmann on Cybersecurity

博客园 - huangyi

垃圾回收 郁闷 MyConsole 白做了 Winform程序中打开控制台 心目中软件开发的未来 把新闻系统转到CommunityServer下的几点体会 css学习笔记 Float CommunityServer下的新闻系统 qq 被人骗走了啊 狗日的 2千多个小时啊 Enterprise Library CommunityServer如何管理Url CommunityServer如何实现属性的动态扩展 CommuntyServer架构分析 web2.0 与 未来网 论坛 博客 相册 留言本 开发计划 微软技术一个共同点 学习avalon的第一个小程序 献丑了 与delphi有关 看到Agent Oriented Programmig感想 Introduce Longhorn to developers(The Longhorn Application Model)[翻译]
css学习笔记 Position
huangyi · 2005-08-23 · via 博客园 - huangyi

Position 有四种取值
    static
    relative
    absolute
    fixed

static定位就是不定位,出现在哪里就显示在哪里,这是默认取值,只有在你想覆盖以前的定义时才需要显示指定

relative 就是相对元素static定位时的位置进行偏移,如果指定static时top是50象素,那么指定relative并指定top是10象素时,元素实际top就是60象素了。

absolute 绝对定位,直接指定top、left、right、bottom。有意思的是绝对定位也是“相对”的。它的坐标是相对其容器来说的。 容器又是什么呢,容器就是离元素最近的一个定位好的“祖先”,定位好的意思就是其Position 是absolute或fixed或relative。 如果没有这个容器,那就使用浏览器初始的,也就是body或者html元素。
 标准是说只需要指定left和right,width可以自动根据容器宽度计算出来,可惜ie不支持。
fixed  才是真正的绝对定位,其位置永远相对浏览器位置来计算。 而且就算用户滚动页面,元素位置也能相对浏览器保持不变, 也就是说永远可以看到,  这个做一些彩单的时候可以用。可惜的是ie还不支持。

最后
不论哪种定位,margin 和padding都应该显示地定义出来,这样在不同浏览器中效果差别会小一些。
当定位了的元素相互交叠,应该指定z-index,z-index越大表示离用户越近。不过z-index也是相对容器来说的。