最近,我重新开始了一些代码,想通过做一个小网站来练习一下。所以,我想用@font-face定义一个自定义字体,我知道应该这样做(我的字体叫做香槟和豪华轿车):
<style>
@font-face {
font-family: 'Champagne & Limousines';
src: url('/fonts/Champagne & Limousines.eot');
src: url('/fonts/Champagne & Limousines.woff2') format('woff2'),
url('/fonts/Champagne & Limousines.woff') format('woff'),
url('/fonts/Champagne & Limousines.ttf') format('truetype'),
url('/fonts/Champagne & Limousines.svg#Champagne & Limousines') format('svg'),
url('/fonts/Champagne & Limousines.eot?#iefix') format('embedded-opentype');
font-weight: normal;
font-style: normal;
}
但是,我想知道为什么我们不用在每行前面加上“src:”。有谁能告诉我背后的逻辑吗?
谢了。
对于在html中使用font-face,您应该在您想要的某些部分使用,例如,如果我想使用'vazir-fd'(这是我们国家的通用字体),我会这样使用它:
@font-face{font-family:'vazir-fd',
src:url('/path')
}
主体{FONT-FAMILY:'Vazir-FD'}
在这种情况下,我把它插入到正文中,你可以在任何你喜欢的地方输入你的font-family。