【问题标题】:Jekyll Bootstrap not importing glyphiconsJekyll Bootstrap 不导入字形图标
【发布时间】:2014-07-30 03:32:48
【问题描述】:

我今天才开始使用 Jekyll,到目前为止我很喜欢它。

我正在使用默认主题之一(简称为bootstrap-3),就文件结构而言,它似乎编译得很好。

但是,当我在本地服务器(或 github.io)上运行它时,一些文件丢失了,尤其是 Bootstrap 默认提供的 glyphicon 字体。

fonts 文件夹存在于_site/assets 目录以及外部assets 目录中,据我所知,_site 目录的内容是服务器上提供的内容。

但是,当我使用 Google 开发工具查找资产时,我根本找不到字体。 CSS 生成得很好,但字体不是。

有趣的是,当我使用另一个主题(如the-project)时,字体加载正常。

我的bootstrap.min.css里面有glyphicons,我唯一能想到的就是url()的代码错了:

src:url('../fonts/glyphicons-halflings-regular.eot') 在我的bootstrap.css 中,并且我的文件结构设置为父文件夹包含fonts 文件夹。

这是我的目录树:

bootstrap-3
├── bootstrap
│   ├── css
│   │   ├── bootstrap.min.css
│   │   └── bootstrap.theme.min.css
│   ├── fonts
│   │   ├── glyphicons-halflings-regular.eot
│   │   ├── glyphicons-halflings-regular.svg
│   │   ├── glyphicons-halflings-regular.ttf
│   │   └── glyphicons-halflings-regular.woff
│   └── js
│       └── bootstrap.min.js
└── css
    └── style.css

还有here is my output site,我想在联系页面的submit 按钮中放置一个字形图标(从主站点看不到,因为我还没有专注于UI)。

有趣的是,当我在按钮中的某处放置一个字形图标时,它会显示出来。

编辑:哇,不小心在类名中添加了>

【问题讨论】:

    标签: twitter-bootstrap-3 jekyll jekyll-bootstrap


    【解决方案1】:

    如果您转到http://getbootstrap.com 并查看网络检查器,您将看不到任何字体加载。但是如果你去http://getbootstrap.com/components/,你会看到他们在浏览器中跳转。

    浏览器仅在需要时才加载字体(如果您使用 glyphicon-xxx 样式)。这称为延迟加载,它可以避免加载不必要的资源。

    编辑 :如果您不在您的网站中使用字形图标,则它们不会被加载。基本的 Jekyll Bootstrap 不使用字形图标。

    尝试在您的一个文件(例如:pages.html)中添加 或在 index.md 中添加等效的 markdown,您将在网络检查器中看到字体加载。

    【讨论】:

    • 好的,这是有道理的,但我的样式表要求@font-face 中的上述字体。我的bootstrap.css 中是否缺少某些内容?我不认为我会,因为这是默认设置,但你永远不知道。
    • 但这就是问题所在,我使用的是字形图标。我有一个空的<span class='glyphicon glyphicon-send'> 标签,我仔细检查以确保该类存在于bootstrap.css
    • 所以,我需要查看您的基本代码或生成的构建。
    • 啊,其实我看到了我的错误。我的span 读到:<span class='glyphicon glyphicon-send>'></span>。错误是克拉进入了类名。哇。谢谢大卫!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2015-01-15
    • 1970-01-01
    • 1970-01-01
    • 2015-07-11
    • 2015-05-30
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多