如何将bootstrap.css字体系列HTML更改为我自己下载的字体

时间:2017-07-18 05:25:16

标签: javascript html css twitter-bootstrap fonts

我试图找到如何做到这一点,至少this link几乎得到了我。但她/他正在使用链接来改变字体。

但是我使用font converter(.eot .otf .svg .ttf .woff .woff2)下载了自己的字体

我有style.css,如下所示:

/* font converted using font-converter.net. thank you! */
@font-face {
  font-family: "CataneoBT-Regular";

  src: url("./fonts/07323Cataneo.svg") format("svg"), /* Legacy iOS */
    url("./fonts/07323Cataneo.ttf") format("truetype"), /* Safari, Android, iOS */
    url("./fonts/07323Cataneo.woff") format("woff"), /* Modern Browsers */
    url("./fonts/07323Cataneo.woff2") format("woff2"); /* Modern Browsers */
  font-weight: normal;
  font-style: normal;
}

这是我的bootstrap.css html:

的一段代码
html {
  font-family: sans-serif;
  -ms-text-size-adjust: 100%;
  -webkit-text-size-adjust: 100%;
}
body {
  margin: 0;
}

我的引导程序最相似的代码是:

@font-face {
  font-family: 'Glyphicons Halflings';
  src: url('../fonts/glyphicons-halflings-regular.eot');
  src: url('../fonts/glyphicons-halflings-regular.eot?#iefix')
  format('embedded-opentype'),
  url('../fonts/glyphicons-halflings-regular.woff2')
  format('woff2'),
  url('../fonts/glyphicons-halflings-regular.woff')
  format('woff'),
  url('../fonts/glyphicons-halflings-regular.ttf')
  format('truetype'),
  url('../fonts/glyphicons-halflings-regular.svg#glyphicons_halflingsregular')
  format('svg');
}
.glyphicon {
  position: relative;
  top: 1px;
  display: inline-block;
  font-family: 'Glyphicons Halflings';
  font-style: normal;
  font-weight: normal;
  line-height: 1;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

但据我所知,这段代码只是为了显示一些图标

我不知道如何将该代码更改为显示我自己的字体

2 个答案:

答案 0 :(得分:2)

只需在CSS文件中使用以下CSS,该文件应包含在bootstrap ..

之后
@font-face {
    font-family: <Your-font>;
    src: url(<your-font-path>);
}
html, body {
    font-family: <Your-font>, sans-serif; /*Specify your font name here*/
    -ms-text-size-adjust: 100%;
    -webkit-text-size-adjust: 100%;
}

答案 1 :(得分:0)

在style.css文件中你需要链接font-family,在 src中提供你的字体路径

@font-face {
 font-family: 'sans-serif';
 font-weight: normal;
 font-style: normal;
 src: url('../fonts/sans-serif.eot') format('embedded-opentype'), url('../fonts/sans-serif.woff') format('woff'), url('../fonts/sans-serif.ttf') format('truetype'), url('../fonts/sans-serif.otf') format('opentype'), url('../fonts/sans-serif.svg#sans-serif') format('svg');
}
相关问题