赞
踩
CSS has several different units for expressing a length. Many CSS properties take "length" values, such as width, margin, padding, font-size, border-width, etc.
CSS 有不同的单位用来描述长度
A whitespace cannot appear between the number and the unit.
表示长度的数字和单位之间不能有空格
However, if the value is 0, the unit can be omitted.
如果长度值为 0, 则单位缺省
For some CSS properties, negative lengths are allowed. 一些CSS属性允许长度是负值
There are two types of length units: relative and absolute.
有两种类型的长度,相对的和绝对的。
specify a length relative to another length property.
相对长度,定义了一个相对于另一个长度属性的长度。
枚举:em, ex, ch, rem, vw, vh, vmin, vmax, %, px
pixels (1px = 1/96th of 1in)
Relative to the font-size of the element (2em means 2 times the size of the current font)
长度是相对于当前字体大小,注意:字体是可继承的,当前字体大小可能有变。
Relative to font-size of the root element
长度是相对于根元素 ( <html>)字体大小而言。因为根元素字体通常定义一次不再改变,使用rem作为长度单位的 CSS 属性因而稳定且consistent。
Bootstrap设定html元素的fontsize是10px
Tip: The em and rem units are practical in creating perfectly scalable layout!
这两种长度单位常用于创建完美的可放大的布局。
The absolute length units are fixed and a length expressed in any of these will appear as exactly that size.
使用绝对长度单位的长度是固定的
They are not recommended for use on screen, because screen sizes vary so much. However, they can be used if the output medium is known, such as for print layout.
因为屏幕的多样性,不建议在 screen 上使用这种单位设定长度。在打印布局时可以使用。
枚举: cm, mm, in, pt, pc
inches (1in = 96px = 2.54cm)
points (1pt = 1/72 of 1in)
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。