您现在的位置:首页 >> 前端 >> 内容

元素marign与padding的百分比设置

时间:2016/12/30 9:32:36 点击:

  核心提示:今天写一个页面,用到padding的百分比,开始以为是相对自身,可是实践之后发现是相对于父元素,查了一些文档。The position and size of an elements box(es) ...

今天写一个页面,用到padding的百分比,开始以为是相对自身,可是实践之后发现是相对于父元素,查了一些文档。

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.

也就是说元素自身的位置跟大小设置的百分比都是相对于父元素。其中位置和大小还有不同的地方: position:元素的margin-top,margin-bottom都是相对于父元素的宽度而不是高度。padding也是这样。

 

Tags:元素 素M MA AR 
作者:网络 来源:mqqqq_1的博客