javascript - 如何将 bootstrap.css font-family HTML 更改为我自己下载的字体

标签 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;
}

我的bootstrap最相似的代码是:

@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;
}

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

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

最佳答案

只需在您的 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%;
}

关于javascript - 如何将 bootstrap.css font-family HTML 更改为我自己下载的字体,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45158184/

相关文章:

javascript - parseInt 可以处理百分比吗?

javascript - 使用 jquery 对图像进行源代码控制?

css - Mixin 属性作为另一个 mixin 的参数?

css - 盒子阴影在 Chrome 和 Firefox 中的不同行为

javascript - 使用 JavaScript 确保发布请求的顺序

javascript - 在表中添加更多行时使用js重新排序表

javascript - 拒绝访问 : Not authorized to perform sts:AssumeRoleWithWebIdentity

javascript - 如何使用 Node/Express 和 HTML 表单按 ID 删除多个项目

CSS/HTML5 : transparent layer with after pseudo-element over fullscreen video tag?

javascript - 如何自动为已经结构化的图像库制作动画?