无聊看文档之CSS-Containing block
2015-03-23 22:38
267 查看
直接上W3C原文:http://www.w3.org/TR/CSS21/visudet.html#containing-block-details
The containing block in which the root element lives is a rectangle called the initial containing block. For continuous media, it has the dimensions of the viewport and is anchored at the canvas origin; it is the page area for paged media. The 'direction' property of the initial containing block is the same as for the root element。包含根元素的一个矩形叫做初始包含块。对于连续的媒体,它具有视窗的尺寸并且是固定在初始画布上的。初始包含块的“方向”属性是和根元素一样的。
For other elements, if the element's position is 'relative' or 'static', the containing block is formed by the content edge of the nearest block container ancestor box.对于其他元素来说,假如元素的定位方式是相对定位或者static定位,那么它的包含块是由最近的块级祖先元素的内容边缘构成。
If the element has 'position: fixed', the containing block is established by the viewport in the case of continuous media or the page area in the case of paged media.固定定位,包含块是当前的可是窗口。
If the element has 'position: absolute', the containing block is established by the nearest ancestor with a 'position' of 'absolute', 'relative' or 'fixed', in the following way:假如元素是绝对定位,那么包含块由最近的带有absolute、relative、fixed定位的祖先构成
In the case that the ancestor is an inline element, the containing block is the bounding box around the padding boxes of the first and the last inline boxes generated for that element. In CSS 2.1, if the inline element is split across multiple lines, the containing block is undefined.在祖先是行内元素的情况下,包含块是由第一个和最后一个内联元素的内边距盒的包含盒构成。在CSS2.1中,假如行内元素被拆分成很多行,那么包含块是undefined。
Otherwise, the containing block is formed by the padding edge of the ancestor.否则,包含块是由祖先的内边距边缘构成。
If there is no such ancestor, the containing block is the initial containing block.假如没有这些祖先元素,包含块就是初始包含块
下面放上一张网上的图
fixed定位验证:
运行时,自行调整视窗大小,fixed定位的div元素的宽度会随着视窗宽度的变化而变化。
博主也是小菜鸟,希望大家看到有什么错误指出来,大家共同成长
10.1 Definition of "containing block"
The position and size of an element's box(es) are sometimes calculated relative to a certain rectangle, called the containing block of the element. The containing block of an element is defined as follows:The containing block in which the root element lives is a rectangle called the initial containing block. For continuous media, it has the dimensions of the viewport and is anchored at the canvas origin; it is the page area for paged media. The 'direction' property of the initial containing block is the same as for the root element。包含根元素的一个矩形叫做初始包含块。对于连续的媒体,它具有视窗的尺寸并且是固定在初始画布上的。初始包含块的“方向”属性是和根元素一样的。
For other elements, if the element's position is 'relative' or 'static', the containing block is formed by the content edge of the nearest block container ancestor box.对于其他元素来说,假如元素的定位方式是相对定位或者static定位,那么它的包含块是由最近的块级祖先元素的内容边缘构成。
If the element has 'position: fixed', the containing block is established by the viewport in the case of continuous media or the page area in the case of paged media.固定定位,包含块是当前的可是窗口。
If the element has 'position: absolute', the containing block is established by the nearest ancestor with a 'position' of 'absolute', 'relative' or 'fixed', in the following way:假如元素是绝对定位,那么包含块由最近的带有absolute、relative、fixed定位的祖先构成
In the case that the ancestor is an inline element, the containing block is the bounding box around the padding boxes of the first and the last inline boxes generated for that element. In CSS 2.1, if the inline element is split across multiple lines, the containing block is undefined.在祖先是行内元素的情况下,包含块是由第一个和最后一个内联元素的内边距盒的包含盒构成。在CSS2.1中,假如行内元素被拆分成很多行,那么包含块是undefined。
Otherwise, the containing block is formed by the padding edge of the ancestor.否则,包含块是由祖先的内边距边缘构成。
If there is no such ancestor, the containing block is the initial containing block.假如没有这些祖先元素,包含块就是初始包含块
下面放上一张网上的图
fixed定位验证:
<!DOCTYPE html> <html> <head> <title>包含块测试</title> <meta content="text/html" charset="utf-8"/> <style type="text/css"> *{ padding:0; margin:0; } #fixed{ width: 50%; height: 90px; background-color: red; position: fixed; bottom: 0px; } </style> </head> <body> <div id="fixed"></div> </body> </html>>
运行时,自行调整视窗大小,fixed定位的div元素的宽度会随着视窗宽度的变化而变化。
博主也是小菜鸟,希望大家看到有什么错误指出来,大家共同成长
相关文章推荐
- 韩顺平_轻松搞定网页设计(html+css+javascript)_第24讲_js案例讲解_js自定义函数_学习笔记_源代码图解_PPT文档整理
- 基于 Django1.10 文档的深入学习(28)—— Managing static files(e.g. images, JavaScript, CSS)
- 前端---CSS文档流
- 新的文档类型定义模型带来的问题--javascirpt/CSS
- jquery、html/css/javascript、jdk、struts1、struts2、hibernate、hibernate annotation、spring等在线文档
- CSSCAN and CSALTER To Be Desupported after DB 11.2. (文档 ID 1418321.1)
- 韩顺平_轻松搞定网页设计(html+css+javascript)_第28讲_js二维数组_js冒泡排序_二分查找_学习笔记_源代码图解_PPT文档整理
- 文档显示部件,文档编辑部件使用CSS制作好看的背景显示效果
- CSS引用条件表达式[摘抄文档]
- CSS学习笔记之文档流
- Umbraco(3) - CSS & Javascript(翻译文档)
- 员提供在线工具,提供jsbin在线 CSS、JS 调试,在线 Java API文档,在线 PHP API文档,在线 Node.js API文档,Less CSS编译器,...
- 在HTML文档中嵌入CSS的三种常用方式
- CSS布局应用到XML文档和HTML文档
- CSS权威指南学习笔记--Chapter1 CSS和文档
- CSS和文档
- JavaScript权威指南_116_第15章_脚本化文档_15.2-选取文档元素-通过CSS类选取元素
- python_html和css文档格式化(一)
- CSS及JS文档中文注释代码在浏览器中显示乱码
- 韩顺平_轻松搞定网页设计(html+css+javascript)_第32讲_构造函数_成员函数详解_学习笔记_源代码图解_PPT文档整理