【问题标题】:Laravel Glyphicons not showingLaravel Glyphicons 没有显示
【发布时间】:2023-03-16 14:47:01
【问题描述】:

Laravel 应用程序未显示字形图标,因为显示错误“加载资源失败:服务器响应状态为 404(未找到)” ?

解决方案:

$ mkdir public/css/fonts

$ cp node_modules/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.ttf 公共/css/字体/

$ cp node_modules/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff 公共/css/字体/

$ cp node_modules/bootstrap-sass/assets/fonts/bootstrap/glyphicons-halflings-regular.woff2 公共/css/字体/

【问题讨论】:

  • 哪个文件具体是404?
  • 我遇到了类似的问题。在 Laravel 5.4(在我的例子中)gluphicons 没有加载。我为这个问题写了一个解决方案here

标签: php twitter-bootstrap laravel glyphicons


【解决方案1】:

我遇到了同样的问题,通过添加解决了这个问题

<link href="//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap-glyphicons.css" rel="stylesheet">

【讨论】:

  • 对我有用,我下载了这个文件,稍后在本地使用
【解决方案2】:

尝试使用

public_path() 

Laravel 提供的函数,它将处理在开发和生产中正确获取公共路径。

如果您要通过刀片文件拉入,请尝试

@font-face{
    font-family:'Glyphicons Halflings';
    src:url({{public_path() . '/css/fonts/<<nameOfFileHere>>'}});
}

如果不完全需要在本地拥有 CDN,您也可以使用它。

<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/font-awesome.min.css" rel="stylesheet">

【讨论】:

    【解决方案3】:

    Glyphicons 在 laravel 7 上不适合我,我发现这篇文章非常有用。它以非常简单的方式解释了如何为 laravel 添加 Glyphicons。

    How to use Glyphicons with a Laravel project

    但我必须做一些小改动才能让它正常工作。

    $icon-font-path: '../fonts/bootstrap/';
    

    $icon-font-path: "~bootstrap-sass/assets/fonts/bootstrap/";
    

    【讨论】:

    • 这是一个死链接:(
    • @Heichou 我记得这个问题是由于从引导程序 4 中删除了字形图标。您可以使用引导程序 3(通过 CDN 或 NPM),也可以使用 fontawesome 库
    • 是的,我用 fontawesome!
    猜你喜欢
    • 2013-06-12
    • 2017-10-11
    • 2015-02-22
    • 2014-12-16
    • 2017-05-01
    • 1970-01-01
    • 2016-10-21
    • 1970-01-01
    • 2015-03-09
    相关资源
    最近更新 更多