@font-face 规则是否可用于其定义的 CSS 文件或可用于其他 CSS 文件和内联 CSS 代码?
Are @font-face rules are usable in it's defined CSS File or usable in other CSS files and inline CSS codes?
我有一堆 CSS 文档,其中有一些 @font-face
规则,我想检查这些 @font-face
哪些在 [=35] 中使用,哪些未使用=] 文档或网站。那么,我应该检查这些 @font-face
在其定义的 CSS 文档中使用的这些 CSS 还是在 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;
}
文件名:另一个-style.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
规则,我想检查这些 @font-face
哪些在 [=35] 中使用,哪些未使用=] 文档或网站。那么,我应该检查这些 @font-face
在其定义的 CSS 文档中使用的这些 CSS 还是在 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;
}
文件名:另一个-style.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 中引用它。