の場合、CSS @ font-faceカスタムフォントは機能しません。問題は、これらのカスタムフォントを別の.cssファイルに追加してこれはフォントソースがhttp://xxxx
<link rel="stylesheet" href="http://lib.mywebsite.eu/content/content.css">
フォントは表示されません。 CSSファイルには、フォントをこのように指していた。
@font-face {
font-family: 'JosefinSansThin';
src: url('fonts/JosefinSansThin.eot');
src: url('fonts/JosefinSansThin.eot') format('embedded-opentype'),
url('fonts/JosefinSansThin.woff2') format('woff2'),
url('fonts/JosefinSansThin.woff') format('woff'),
url('fonts/JosefinSansThin.ttf') format('truetype'),
url('fonts/JosefinSansThin.svg#JosefinSansThin') format('svg');}
だから私はこのようなhtmlファイルに全体のCSSをコピーしようとした:
<style type='text/css'>
@font-face {
font-family: 'JosefinSansThin';
src: url('/subdom/lib/content/fonts/JosefinSansThin.eot');
src: url('/subdom/lib/content/fonts/JosefinSansThin.eot') format('embedded-opentype'),
url('/subdom/lib/content/fonts/JosefinSansThin.woff2') format('woff2'),
url('/subdom/lib/content/fonts/JosefinSansThin.woff') format('woff'),
url('/subdom/lib/content/fonts/JosefinSansThin.ttf') format('truetype'),
url('/subdom/lib/content/fonts/JosefinSansThin.svg#JosefinSansThin') format('svg');}</style>
とブーム!出来た。 しかし、私はindex.phpでしか使用したくないので、他のhtml/phpファイルに入れる必要があります.->外部ファイルにする必要があります。だから、私の次の試みは、PHPでそれを含めることだった:それは働いた
<style type='text/css'>
<?php
include $_SERVER['DOCUMENT_ROOT'].'/subdom/lib/content/content.css';
?>
</style>
が、道の作品が含まれているため、それがインデックスにあったかのように、外部CSSでフォントに同じパスをが存在しなければなりません.php - '/ subdom/lib/content/fonts ...'となっているので、ルート以外のフォルダには使用できません。 アドレスhttp://lib.mywebsite.eu/content/fonts/JosefineSansThin.xxx(これはhttp://mywebsite.eu/subdom/lib/content/fonts/JosefineSansThin.xxxと同じです)を指すことができれば、すべて問題ありません。 なぜそれがうまくいかないのでしょうか?ありがとう!
これは私が今すぐ持っている方法で、PHPのインクルードを使用してindex.phpにインクルードします。しかし、もし私がメインフォルダ(例えば、http://mywebsite.eu/blog/index.php上)にないPHPでそれを使用した場合、アドレスhttp://mywebsite.eu/blog/subdom/lib ...は存在しません。 –
これは起こらないはずです - 最初のスラッシュはルートを示します。 http://mywebsite.eu/blog/index.phpで参照する場合は、http://mywebsite.eu/subdom/libを参照する必要があります。 –
私はとてもばかげている! Ofc。私は絶対的なリンクを持っていなかった...あなたの助けをありがとう、私はとても恥ずかしい感じる –