gpt4 book ai didi

css - 在@font-face 中,声明格式有什么作用?

转载 作者:太空宇宙 更新时间:2023-11-04 09:21:44 27 4
gpt4 key购买 nike

例如,在我发现 here 的这个@fontface 声明中,CSS 有一个 format('truetype') 表明它是一个 .tff。但是在我的程序中,有和没有没有区别。

font-face {
font-family: 'DroidSerif';
src: url('DroidSerif-Bold-webfont.ttf') format('truetype');
font-weight: bold;
font-style: normal;
}

最佳答案

format 用于帮助浏览器在不能自动推断的情况下理解字体格式。

现代浏览器会喜欢字体扩展名(在您的情况下为 .ttf)或可能是 mime-type并自动推断它而无需明确指定格式。

可能您今天需要它的唯一原因是您使用的是非标准文件扩展名,或者根本没有扩展名,或者可能没有使用正确的 mime 类型。

关于css - 在@font-face 中,声明格式有什么作用?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41447487/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com