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 像素 ?計算機屏幕上的一個點)
The?px?unit is the magic unit of CSS. It is not related to the current font and usually not related to physical centimeters or inches either. The?px?unit is defined to be small but visible, and such that a horizontal 1px wide line can be displayed with sharp edges (no anti-aliasing). What is sharp, small and visible depends on the device and the way it is used: do you hold it close to your eyes, like a mobile phone, at arms length, like a computer monitor, or somewhere in between, like an e-book reader? The?px?is thus not defined as a constant length, but as something that depends on the type of device and its typical use.
px單元是CSS的神奇單元。 它與當前字體無關,通常與物理厘米或英寸無關。 px單元被定義為小但可見,并且可以顯示具有銳邊的水平1px寬線(無抗鋸齒)。 什么是鋒利的,小的和可見的取決于設備及其使用方式:你把它靠近你的眼睛,如手機,手臂長度,如電腦顯示器,或介于兩者之間,如電子閱讀器? 因此,px不被定義為恒定長度,而是取決于設備的類型及其典型用途。
?
轉載于:https://www.cnblogs.com/BigWatermelon/p/9756473.html
總結
- 上一篇: java web: Servlet JS
- 下一篇: CSS 基本样式