html - @font-face 不工作。我是新手 html & css 用户

标签 html css font-face

 @font-face
   {
    font-family: 'trajan';
    src:
        url ('fonts/trajan.otf'),
        url ('fonts/trajan.eot'),
        url ('fonts/trajan'),
        url ('fonts/trajan.woff'),
        url ('fonts/trajan2'),
        url ('fonts/trajan3');
   }


 #customfont{

    color: white;
    list-style: none;
    font-size: 40px;
    font-family: trajan;

}

HTML

<div id="customfont">
    <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit</p>
</div>

字体大小改变。看来我只有自定义字体部分搞砸了。我已将字体存储在名为“字体”的文件夹中

最佳答案

我不知道这是否有任何区别,但你有一个没有扩展名的 url ( url ('fonts/trajan') )

或者你的路径可能不对(也许你的 CSS 在一个文件夹中,你需要上一个文件夹?)。

无论如何,这是我用于@font-face 的结构:

/* FONTS */
@font-face {
  font-family: 'trajan';
  font-style: normal;
  font-weight: 100;
  src: url('fonts/trajan.eot');
  src: url('fonts/trajan.eot?#iefix') format('embedded-opentype');
  src: local('trajan'), url(fonts/trajan.woff) format('woff');
}

关于html - @font-face 不工作。我是新手 html & css 用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23654963/

相关文章:

css - 嵌入字体会阻止斜体工作,它最初是如何工作的?

html - Gulp将多个css文件编译成一个

javascript - 取消 图片未在 uploadify 中显示

javascript - 集成 jQuery Slider 搞乱了设计

css - 使用 CSS 的六边形图案

HTML 下拉菜单使 <div> 高度变长

css - 为什么我们应该在字体中包含 ttf、eot、woff、svg...

javascript - iPad/Mac Safari 不会加载字体

html - 删除 Bootstrap 模式弹出窗口中的垂直滚动条

html - 表格中图像背景的透明度