简体   繁体   English

外部CSS中的多种字体

[英]Multiple font-face in external css

I know that it's possible to have multiple font-faces on css. 我知道在CSS上可能有多个字体 Now I have two html pages that use these fonts but in the future there'll be more; 现在我有两个使用这些字体的html页面,但是将来会有更多。 now those font-faces are declared via inline css and used via classes. 现在,这些字体通过内联css声明并通过类使用。 What I really wanted was to wrap up all my font-faces into a single fonts.css and then on each individual html pages reference that css and use <p class="...-font"><p> 我真正想要的是将我所有的字体都包装到单个fonts.css中,然后在每个单独的html页面上引用css并使用<p class="...-font"><p>

So my fonts' css is like this: 所以我字体的css是这样的:

@font-face {
        font-family: 'Komika';
        src: url('/bin/res/font/KOMIKAX_-webfont.eot');
        src: url('/bin/res/font/KOMIKAX_-webfont.eot?#iefix') format('embedded-opentype'),
        url('/bin/res/font/KOMIKAX_-webfont.woff') format('woff'),
        url('/bin/res/font/KOMIKAX_-webfont.ttf') format('truetype'),
        url('/bin/res/font/KOMIKAX_-webfont.svg#KomikaAxisRegular') format('svg');
        font-weight: normal;
        font-style: normal;
}
.komika-font {font: 30px 'Komika', Tahoma, sans-serif;}

@font-face {
        font-family: 'Nevis';
        src: url('/bin/res/font/nevis-webfont.eot');
        src: url('/bin/res/font/nevis-webfont.eot?#iefix') format('embedded-opentype'),
        url('/bin/res/font/nevis-webfont.woff') format('woff'),
        url('/bin/res/font/nevis-webfont.ttf') format('truetype');
        font-weight: normal;
        font-style: normal;
}
.nevis-font {font: 500% 'Nevis', Tahoma, sans-serif;}

And the html is like this: 和HTML是这样的:

<head>
<link rel="stylesheet" href="/bin/res/style-fonts.css.php" type="text/css" />
<link rel="stylesheet" href="/bin/res/style.css.php" type="text/css" />
<title><?php echo $photo_title ?></title>
</head>

<body>
    <h1 class="____">Some text here</h1>
<body>

And at the ____ should be "nevis-font" but the IDE (Dreamweaver) doesn't even autocomplete. ____应该是“ nevis-font”,但IDE(Dreamweaver)甚至不会自动完成。

Is it possible? 可能吗? Because I tried it and it didn't work (the chosen font wasn't displayed). 因为我尝试了它,但是它不起作用(未显示所选字体)。


I think I got it, the problem was that the css containing the font-faces can't end with .php like I had. 我想我明白了,问题是包含字体的css无法像我一样以.php结尾。 I just use *.css.php because the .php forces the server to compress the css files. 我只使用* .css.php,因为.php会强制服务器压缩css文件。

Yes it's possible. 是的,有可能。 We'll need more details on the problem you used to have in order to answer a more detailed answer. 我们将需要更多有关您曾经遇到的问题的详细信息,以便回答更详细的答案。

The problem was that the css containing the font-faces can't end with .php like I had. 问题是包含字体的css不能像我一样以.php结尾。 I just use *.css.php because the .php forces the server to compress the css files. 我只使用* .css.php,因为.php会强制服务器压缩css文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM