好吧,我一直在尝试在页面上添加自定义字体,这不是您在任何计算机上都能找到的字体。我尝试通过遵循this来实现此功能,但它似乎默认为Agency FB。这是CSS:

@font-face  {
  font-family: "911";
  src: url('fonts/911v2.eot'); /* here you go, IE */
}

@font-face  {
  font-family: "911";
  src: url(//:) format ('no404'), url('fonts/911v2.ttf') format('truetype'); /* tricky! */
}

p.myFont {
    font-family: "911", "Agency FB", verdana, helvetica, sans-serif;
    font-size: large;
    color: black;
}


我使用转换器将字体从ttf转换为eot。这是相关的HTML:

<p class="myFont">Once upon a midnight dreary, while I pondered weak and weary</p>


有任何想法吗?

请注意,fonts文件夹位于网页的根目录(索引页所在的位置)中

编辑:

 在字体文件夹中->

编辑2:

仍然不起作用,但是这是我目前所能得到的:

@font-face {
  font-family: '911';
  src: url('/fonts/911v2.eot');
  src: local('☺'), url('/fonts/911v2.ttf') format('truetype');
}

p.myFont {
    font-family: '911', "Agency FB", verdana, helvetica, sans-serif;
    font-size: large;
    color: black;
}

最佳答案

我使用fontsquirrel.com中的字体包。为了在最广泛的浏览器中工作,css的外观如下:

@font-face {
    font-family: "OpenSansLight";
    src: url("/fonts/OpenSans-Light-webfont.eot");
    src: url("/fonts/OpenSans-Light-webfont.eot?#iefix") format("embedded-opentype"),
         url("/fonts/OpenSans-Light-webfont.woff") format("woff"),
         url("/fonts/OpenSans-Light-webfont.ttf") format("truetype"),
         url("/fonts/OpenSans-Light-webfont.svg#OpenSansLight") format("svg");
    font-weight: normal;
    font-style: normal;
}

h2 {
  font: 16pt "OpenSansLight", sans-serif;
  color: #fff;
}


我目前在我的一些网站中使用它,效果很好!

10-06 07:42
查看更多