7个CSS单位
来源:互联网 发布:java main 编辑:程序博客网 时间:2024/06/12 00:59
五、ex 和 ch
ex、ch单位与em、rem相似之处在于都依赖于font-size,但是ex、ch还依赖于font-family,基于font-specific来计算。 引用w3C规范:
ex unit Equal to the used x-height of the first available font. [CSS3-FONTS] The x-height is so called because it is often equal to the height of the lowercase “x”. However, an ‘ex’ is defined even for fonts that do not contain an “x”. The x-height of a font can be found in different ways. Some fonts contain reliable metrics for the x-height. If reliable font metrics are not available, UAs may determine the x-height from the height of a lowercase glyph. One possible heuristic is to look at how far the glyph for the lowercase “o” extends below the baseline, and subtract that value from the top of its bounding box. In the cases where it is impossible or impractical to determine the x-height, a value of 0.5em must be assumed.
ch unit Equal to the used advance measure of the “0” (ZERO, U+0030) glyph found in the font used to render it.
用一副图来解释这两种单位的含义:
css-units
这两种单位,有许多用途,大部分是用于印刷时的微调整。例如,sup、sub元素分别显示上标和下标,但是我们可以使用position和bottom模拟:
body {
margin: 0;
padding:0;
}
.sup {
position: relative;
bottom: 1ex;
}
.sub {
position: relative;
bottom: -1ex;
}
- 7个CSS单位
- 7个CSS单位
- CSS:7个你可能不认识的单位
- CSS:7个你可能不认识的单位
- 7个你可能不认识的CSS单位
- CSS:7个你可能不认识的单位
- 7个你可能不认识的CSS单位:r…
- 7个你可能不认识的CSS单位:rem vh vw vmin vmax ex ch
- 7个你可能不认识的CSS单位:rem vh vw vmin vmax ex ch
- 7个你可能不认识的CSS单位:rem vh vw vmin vmax ex ch
- 7个你可能不认识的CSS单位:rem vh vw vmin vmax ex ch
- CSS 单位
- CSS 单位
- CSS单位
- CSS 单位
- CSS单位
- CSS 单位
- CSS单位
- 2017年要学习的三个CSS新特性
- JSON 修改问题:浅拷贝 和 深拷贝
- Web App 和 Native App,哪个是趋势?
- LeetCode 382. Linked List Random Node
- [BZOJ4443][Scoi2015]小凸玩矩阵 二分法+二分图匹配
- 7个CSS单位
- javascript基础:prototype对象的继承
- Android打包——详解build.gradle
- git tag
- 多线程的异常捕捉
- 3D游戏开发之在UE4中创建非玩家角色(NPC)
- opencv3异常 库找不到 no such file
- 万能头文件#include<bits/stdc++.h>
- ARC内存管理,防止内存泄漏,带retain、assign、strong、weak、nonatomic参数property和synthesize应用总结