CSS中的单位

absolute units

  • in 英寸
  • cm 厘米
  • mm 毫米  
  • pt 磅 (1 pt 等于 1/72 英寸)
  • pc  12点活字 (1 pc 等于 12 点)

The relation between the absolute units is as follows: 1in = 2.54cm = 25.4mm = 72pt = 6pc

绝对单位之间的关系如下:1in = 2.54cm = 25.4mm = 72pt = 6pc

relative units

  • em

  1em 等于当前的字体尺寸。

  2em 等于当前字体尺寸的两倍。

  例如,如果某元素以 12pt 显示,那么 2em 是24pt。

  在 CSS 中,em 是非常有用的单位,因为它可以自动适应用户所使用的字体。

  The em and ex units depend on the font and may be different for each element in the document. The em is simply the font size. In an element with a 2in font, 1em thus means 2in. Expressing sizes, such as margins and paddings, in em means they are related to the font size, and if the user has a big font (e.g., on a big screen) or a small font (e.g., on a handheld device), the sizes will be in proportion. 

  em和ex单位取决于字体,对于文档中的每个元素可能不同。 em只是字体大小。 在具有2英寸字体的元素中,1em因此意味着2英寸。 在em中表示大小(例如边距和填充)意味着它们与字体大小相关,并且如果用户具有大字体(例如,在大屏幕上)或小字体(例如,在手持设备上),则尺寸会保持比例。

 

  • ex

  一个 ex 是一个字体的 x-height。 (x-height 通常是字体尺寸的一半。)

  The ex unit is rarely used. Its purpose is to express sizes that must be related to the x-height of a font. The x-height is, roughly, the height of lowercase letters such as a, c, m, or o. Fonts that have the same size (and thus the same em) may vary wildly in the size of their lowercase letters, and when it is important that some image, e.g., matches the x-height, the ex unit is available.

 

  ex单位很少使用。 其目的是表示必须与字体的x-height相关的大小。 x高度大致是小写字母的高度,例如a,c,m或o。 具有相同大小(并因此相同的em)的字体可能在其小写字母的大小上变化很大,并且当一些图像(例如,匹配x-height)很重要时,ex单元是可用的。

 

  • px 像素  计算机屏幕上的一个点

    px不被定义为恒定长度,而是取决于设备的类型及其典型用途。

     

转载于:https://www.cnblogs.com/HL345/p/9892544.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值