【发布时间】:2016-10-18 11:22:55
【问题描述】:
我正在尝试向我的网站添加自定义字体。
CSS 代码
@font-face {
font-family: 'dhananjayawebregular';
src: url('dhananjaya_web_sinhala_font-webfont.eot');
src: url('dhananjaya_web_sinhala_font-webfont.eot?#iefix') format('embedded-opentype'),
url('dhananjaya_web_sinhala_font-webfont.woff2') format('woff2'),
url('dhananjaya_web_sinhala_font-webfont.woff') format('woff'),
url('dhananjaya_web_sinhala_font-webfont.ttf') format('truetype'),
url('dhananjaya_web_sinhala_font-webfont.svg#dhananjayawebregular') format('svg');
font-weight: normal;
font-style: normal;
}
#sinhala {font-family:dhananjayawebregular;}
#dhananjayaweb {font-family:dhananjayawebregular;}
PHP 代码
<div class="cell">
<a href="<?php echo "$name_html-news$id.html";?>">
<div class="newstitle" id="dhananjayaweb"><?php echo $title;?></div>
<div class="newsname"><?php echo $name;?></div>
</a>
<div class="shortnews" id="dhananjayaweb"><?php echo substr($news1, 0, strpos($news1, ' ', 140));?>'''</div>
<div class="newsother">
<?php echo $views;?> views |
Date : <?php echo $date;?>
</div>
</div>
但它只能在 localhost(windows) 中正常工作。当我将脚本上传到网络主机(Linux)时,字体无法正确显示
我尝试了所有可以在网上找到的东西,但仍然无法正常工作。我拼命想让这个工作。请帮忙。
【问题讨论】:
-
您可以尝试在路径前添加
/ -
例如
src: url('/dhananjaya_web_sinhala_font-webfont.eot'); -
你能解释一下为什么吗?它仍然什么也没做。
-
斜线表示资源位于服务器上。但是大多数服务器都设置为默认查看服务器,除非他们看到
"http://"。 -
在我的情况下,它读取字体,但不能正确显示,比如它的包装或其他东西。看这里pituva.com