简体   繁体   English

通过font face在css中导入字体

[英]import font in css through font face

font is not working字体不起作用

here is CSS code这是 CSS 代码

@font-face {
  font-family: 'Soolidium', sans-serif;
  font-style: normal;
  src:url(http://localhost/changingCinema/font/Soolidium.ttf) format('truetype');
}

heading
        {
            float:left;
            width:100%;
            margin-bottom:10px;
            font-size:54px;
            font-family: 'Soolidium', sans-serif;}

this is HTML这是 HTML

<heading>My heading</heading>

only working when I install this font in my window otherwise not.仅当我在窗口中安装此字体时才有效,否则无效。

Help me plz fast thank you.请帮我快点谢谢。

In Font face set font family name在 Font face 中设置字体系列名称

@font-face {
  font-family: 'Soolidium';
  font-style: normal;
  src: url('http://localhost/changingCinema/font/Soolidium.ttf') format('truetype'); 
  }

For all browser support you have to give url from different font file.对于所有浏览器支持,您必须提供来自不同字体文件的 url。 (.eot/.woff/.ttf/.svg) (.eot/.woff/.ttf/.svg)

First of all make sure you put your @font-face before any other styles.首先,请确保将 @font-face 放在任何其他样式之前。

If possible you might also need to add additional rules for browser support like this:如果可能,您可能还需要为浏览器支持添加其他规则,如下所示:

@font-face {
    font-family: 'Soolidium', sans-serif;
    src: url('Soolidium.woff2') format('woff2'),
    url('Soolidium.woff') format('woff'),
    url('Soolidium.ttf') format('truetype');
}

And as always check for spelling errors or pointing to the wrong path.并一如既往地检查拼写错误或指向错误的路径。 Remember you are calling this from your CSS file so you need to point relatively to the font folder.请记住,您是从 CSS 文件中调用它的,因此您需要相对指向字体文件夹。

Try replacing:尝试更换:

src:url(http://localhost/changingCinema/font/Soolidium.ttf) format('truetype');

with:和:

src: url('../font/Soolidium.ttf');

Assuming you have a folder named 'font' in your root directory with the font 'Soolidium.ttf' in.假设您的根目录中有一个名为“font”的文件夹,其中包含字体“Soolidium.ttf”。

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

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