码迷,mamicode.com
首页 > Web开发 > 详细

CSS中的单位

时间:2018-11-01 22:30:55      阅读:270      评论:0      收藏:0      [点我收藏+]

标签:hat   相同   purpose   case   hand   between   并且   ima   letters   

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不被定义为恒定长度,而是取决于设备的类型及其典型用途。

     

CSS中的单位

标签:hat   相同   purpose   case   hand   between   并且   ima   letters   

原文地址:https://www.cnblogs.com/HL345/p/9892544.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!