css - 在@font-face 中添加行高
问题描述
有什么方法可以line-height
代替@font-face
, :root
, body
, & 其他元素添加*
吗?div
我在网络应用程序中使用了多种字体。例如,我们使用了 Lato & Roboto 字体。如果应用 Lato 字体我需要给line-height: 1.4em
,如果应用 Roboto 字体我需要给line-height: 1.6em
。有什么方法可以添加line-height
或@font-face
任何其他技巧吗?
* {
margin: 0;
padding: 0;
}
@font-face {
font-family: myFont;
src: url(https://fonts.gstatic.com/s/tangerine/v11/IurY6Y5j_oScZZow4VOxCZZMprNA4A.woff2) format('woff2');
font-weight: 400;
font-style: normal;
line-height: 40px;
}
div {
font-family: myFont;
font-size: 32px;
}
<div>
Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only five centuries, but also the leap into electronic typesetting, remaining essentially unchanged. It was popularised in the 1960s with the release of Letraset sheets containing Lorem Ipsum passages, and more recently with desktop publishing software like Aldus PageMaker including versions of Lorem Ipsum.
</div>
<br/><br/><br/>
<p>
Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book. It has survived not only
</p>
解决方案
你可以做的是:
font : (font-size)/(line-height) (font-family)
这一行相当于:
font-size : ....
line-height:....
font-family:....
你仍然需要使用 src
推荐阅读
- c++ - “-std=c++17 无法通过命令行识别”在 Windows 中构建崇高文本时
- visual-studio-code - 在 VSCode 中浏览大文件中的行/列
- php - 从时间戳创建日期和时间的php数组
- python - 安装包后,包什么时候可见?
- c# - Web 浏览器无法使用 .net 桌面应用程序中的 Firebase SignInWithOAuth 打开或打开一次
- python - AttributeError:模块'tokenize'没有属性'open'
- php - 更改 PHP-FPM (Docker) 的用户/组
- r - 无法通过重新排序重新排序 R ggplot geom_bar() 函数中的条形图
- pycharm - 在启动 Qt5 应用程序的主要 python 脚本之前,如何使用 Pycharm 直接运行资源创建脚本?
- php - 图表 JS 轴扩展