« | September 2025 | » | 日 | 一 | 二 | 三 | 四 | 五 | 六 | | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | | | | | |
|
公告 |
My blog is about my major : network security.the most papers are talk about it ,I like my major ,i wish you could find what's you need in it. |
统计 |
blog名称:我的IT人生 日志总数:78 评论数量:185 留言数量:-1 访问次数:526765 建立时间:2006年4月5日 |
| 
|
本站首页 管理页面 写新日志 退出
[HTML+CSS+JS]absolute & relative 定位大法 |
Position: absolute 与relative
一,定义:
绝对是说其位置完全取决于浏览器左边上方原始顶点或父容器的左边上方原始顶点。不受其他网页元素的影响,飘浮。
相对是说在自己的范围内,内部元素的位置相对与自己而定。
二,结论:
对一个容器e.g <div id=”test”>来说,使用绝对定位的四个先决条件:
1, test有position:absolute属性
2, 存在任意的一个父容器e.g <div id=”father”>有position:relative属性
3, test有top right botom left属性中的一个或多个
4, test有margin-right margin-top margin-bottom margin-left属性中的一个或多个
满足1+3 或 1+3+4 : test相对于浏览器的原始点依据3中的属性绝对定位;
满足1+2+3 或 1+2+3+4: test相对于father依据3中的属性绝对定位;
满足1+4 : test相对于father依据4中的属性绝对定位;
三,其他:
当需要指定容器的层叠关系时,还可以使用z-index来指定(父子关系除外)。
|
阅读全文(2666) | 回复(0) | 编辑 | 精华 |
|