简体   繁体   English

HTML / CSS CSS字体系列不显示某些元素的字体

[英]Html/Css font-family does not show the font for some element

I'm writing a very basic site with only html/css. 我正在写一个只有html / css的非常基本的网站。 I downloaded some fonts (each font have only 1 file ttf/otf). 我下载了一些字体(每个字体只有1个文件ttf / otf)。 In localhost, (with Chrome) i wrote all, and all works perfectly. 在localhost(使用Chrome)中,我编写了所有内容,并且一切运行正常。 When i put it on a server (in my case altervista) it does not work for altervista. 当我将其放在服务器(在我的情况下是altervista)上时,它不适用于altervista。 Works only 1 font of 2 that i used. 我只能使用2的一种字体。 For css file i have: 对于css文件,我有:

    @font-face 
    { 
        font-family: PirateOne; 
        font-weight: bold; 
        src: url('fonts/PirataOne-Regular.ttf');
    }
    @font-face 
    { 
        font-family: SoTFont; 
        src: url('fonts/Windlass.ttf');
    }

for the 2 fonts. 2种字体。 So the first works good for all where i allocated it, the second one not. 因此,第一个对我分配的所有位置都有效,第二个则不然。 SO i tried to associate at the element with the second one, the first, but they continue to not work. 因此,我尝试将元素与第二个元素(第一个元素)相关联,但是它们仍然无法正常工作。 I tried with 3others font (that in locally work). 我尝试使用3others字体(在本地工作)。

In the index.html i have: 在index.html中,我有:

    <BODY id="bodyindex">

    <p class="title"> My Site </p>

     .........
    </body>

and in css file: 并在css文件中:

    p.title
    {
        font-size: 275%;
        font-family: SotFont;
        text-align: center;
        color: lightblue;
        margin: 20 0 0 0;
    }

and the same for other 2 p. 和其他2 p相同。 i tied with font-family: "SotFont"; 我与font-family: "SotFont";捆绑在一起font-family: "SotFont"; , with font-family: PirateOne; font-family: PirateOne; or font-family: "PirateOne"; font-family: "PirateOne";

but nothing...in local all this test works perfectly and the font loads, but in altervista..nothing..it not load. 但是什么也没有...在本地所有测试都可以完美地工作并加载字体,但是在altervista..nothing ..中则不会加载。 How can i solve? 我该如何解决? Thank you 谢谢

ps. PS。 i read some discussion on google, and in particular here, but nothing solved my problem also adding format('truetype') or opentypè haven't solved. 我在google上阅读了一些讨论,尤其是在这里,但没有任何解决方案,我的问题也没有解决,添加format('truetype') or opentypè也没有解决。

thank you 谢谢

EDIT: Chrome saved cache with err name of font usage. 编辑:Chrome使用字体用法的错误名称保存了缓存。 WIth Hidden Navigation i see that all fonts work correctly 通过隐藏导航,我看到所有字体都能正常工作

The font name declared and used are different. 声明和使用的字体名称不同。 Try aligning them and clear the cache and reload the browser. 尝试对齐它们并清除缓存,然后重新加载浏览器。 It should work for you. 它应该为您工作。

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

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