【问题标题】:CSS Custom font not showing properly in web host but localhostCSS 自定义字体未在 Web 主机中正确显示,但在 localhost
【发布时间】: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));?>&#39&#39&#39</div>
                    <div class="newsother">
                        <?php echo $views;?> views |
                        Date : <?php echo $date;?>
                    </div>
                </div>

但它只能在 localhost(windows) 中正常工作。当我将脚本上传到网络主机(Linux)时,字体无法正确显示

screenshot on localhost

Screenshot on web host

我尝试了所有可以在网上找到的东西,但仍然无法正常工作。我拼命想让这个工作。请帮忙。

【问题讨论】:

  • 您可以尝试在路径前添加/
  • 例如src: url('/dhananjaya_web_sinhala_font-webfont.eot');
  • 你能解释一下为什么吗?它仍然什么也没做。
  • 斜线表示资源位于服务器上。但是大多数服务器都设置为默认查看服务器,除非他们看到"http://"。
  • 在我的情况下,它读取字体,但不能正确显示,比如它的包装或其他东西。看这里pituva.com

标签: php html css fonts


【解决方案1】:

说起来很遗憾,但我忘了在标题上添加这一行:D

<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />

现在一切都很好。 感谢大家的帮助,非常感谢您的帮助。

【讨论】:

    猜你喜欢
    • 2012-12-28
    • 2019-07-15
    • 2011-07-21
    • 2011-07-21
    • 2012-03-22
    • 2019-08-01
    • 2020-08-31
    • 1970-01-01
    • 2011-10-08
    相关资源
    最近更新 更多