javascript - 如何在 Css 中为文本设置字体?
问题描述
有没有办法为css中的文本设置像“ Intro Black Regular ”这样的字体?!IDE 将“黑色”检测为一种颜色,而不是字体名称的一部分。
解决方案
您需要按照 3 个步骤使用字体作为文本
设置
@font-face
设置
font-family
名称font-family
在 css 中使用
<!DOCTYPE html>
<html>
<head>
<style>
@font-face {
font-family: myFirstFont;
src: url(sansation_light.woff);
}
div {
font-family: myFirstFont;
}
</style>
</head>
<body>
<h1>The @font-face Rule</h1>
<div>With CSS, websites can finally use fonts other than the pre selected "web-safe" fonts.</div>
<p><b>Note:</b> Internet Explorer 8 and earlier, do not support the WOFF format (only supports EOT format).</p>
</body>
</html>
推荐阅读
- qt - QT 多线程中 UI 显示的延迟
- .net - Serilog Map sink 日志文本
- android - 三星设备 4 和 5 中的拍照图像加载问题
- ruby-on-rails - 在 OSX catalina(10.15.1) 中使用 rbenv 安装 ruby-2.4.0 时构建失败(OS X 10.15.1 使用 ruby-build 20191124)
- c++ - 为我的 ESP32 服务器分配静态 IP 后不再响应
- javascript - 使用 Audio Worklets 时如何修复“破解”音频?
- java - 私有方法的 AOP 注释
- asp.net-core - 如何处理多层1对多关系的DAL?
- c - 什么种族导致输出看起来不同?
- php - php图像上传并添加文本