CSS单位

本文详细介绍了CSS中各种单位的含义及应用场景,包括相对单位如em、ex,绝对单位如px、pt,视口单位如vw、vh,以及特殊单位如ch、cap等。这些单位在网页布局和字体大小调整中扮演着重要角色。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

CSS单位
cap
Represents the "cap height" (nominal height of capital letters) of the element’s  font.
ch
Represents the width, or more precisely the advance measure, of the glyph "0" (zero, the Unicode character U+0030) in the element's  font.
em
Represents the calculated  font-size of the element. If used on the font-size property itself, it represents the inherited font-size of the element.
ex
Represents the  x-height of the element's font. On fonts with the "x" letter, this is generally the height of lowercase letters in the font; 1ex ≈ 0.5em in many fonts.
ic
Equal to the used advance measure of the "水" (CJK water ideograph, U+6C34) glyph found in the font used to render it
. lh
Equal to the computed value of the  line-height property of the element on which it is used, converted to an absolute length.
rem
Represents the  font-size of the root element (typically <html>). When used within the root element font-size, it represents its initial value (a common browser default is 16px, but user-defined preferences may modify this).
rlh
Equal to the computed value of the  line-height property on the root element (typically <html>), converted to an absolute length. When used on the font-size or line-height properties of the root element, it refers to the properties' initial value.
 
vh
Equal to 1% of the height of the viewport's initial containing block.
vw
Equal to 1% of the width of the viewport's initial containing block.
vi
Equal to 1% of the size of the initial containing block, in the direction of the root element’s inline axis.
vb
Equal to 1% of the size of the initial containing block, in the direction of the root element’s block axis.
vmin
Equal to the smaller of vw and vh.
vmax
Equal to the larger of vw and vh.

转载于:https://www.cnblogs.com/liyifeng0528/p/9780838.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值