gpt4 book ai didi

css - @font-face 规则是否可用于其定义的 CSS 文件或可用于其他 CSS 文件和内联 CSS 代码?

转载 作者:太空宇宙 更新时间:2023-11-04 06:39:06 26 4
gpt4 key购买 nike

我有一堆 CSS 文档,里面有一些 @font-face 规则,我想检查这些 @font-face 哪些被使用,哪些没有在 HTML 文档或网站中使用。那么,我应该检查在它定义的 CSS 文档中使用的这些 @font-face 还是在 HTML 文档中使用内联样式标签的所有 CSS 文档?

问题是,这个;

文件名:style.css

@font-face {
font-family:'FontAwesome';
src:url('../fonts/fontawesome-webfont.eot?v=4.7.0');
src:url('../fonts/fontawesome-webfont.eot?#iefix&v=4.7.0') format('embedded-opentype'),
url('../fonts/fontawesome-webfont.woff2?v=4.7.0') format('woff2'),
url('../fonts/fontawesome-webfont.woff?v=4.7.0') format('woff'),
url('../fonts/fontawesome-webfont.ttf?v=4.7.0') format('truetype'),
url('../fonts/fontawesome-webfont.svg?v=4.7.0#fontawesomeregular') format('svg');
font-weight:normal;
font-style:normal
}

/* This tag can use the @font-face, because this .any-class rule in same CSS document */
.any-class {
font-family: 'FontAwesome',
font-weight: normal;
}

文件名:另一个样式.css

/* Can this CSS Class use the @font-face in style.css ? */
.any-other-class {
font-family: 'FontAwesome',
font-weight: normal;
}

文件名:index.html

<html>
<head>
<link rel="stylesheet" href="style.css">
<style>
/* Can this .custom-class CSS Selector use @font-face in style.css ? */
.custom-class {
font-family: 'FontAwesome',
font-weight: normal
}
</style>
</head>
<body>
<!-- Can this DOM Element use @font-face in style.css? -->
<p style="font-family: 'FontAwesome'; font-weight: normal;">Hello!</p>
</body>
</html>

最佳答案

是的,只要你在任何你想使用你的网络字体的地方包含 style.css,你在这里的一切都会起作用,例如您使用 link 的方式。您的 @font-face 规则与任何其他 CSS 规则一样,不必出现在与引用它的 CSS 规则相同的样式表中,也不必出现在任何具有引用它的内联样式的 HTML 中。

关于css - @font-face 规则是否可用于其定义的 CSS 文件或可用于其他 CSS 文件和内联 CSS 代码?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53968350/

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