如何将引导程序和外部 css 链接到 Laravel 5.3?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/41328363/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 15:00:38  来源:igfitidea点击:

how to link bootstrap and external css into laravel 5.3?

csslaravellaravel-5.3

提问by HirenMangukiya

i try to add bootstrap and external css file into my laravel project using two methods

我尝试使用两种方法将引导程序和外部 css 文件添加到我的 Laravel 项目中

<link rel="stylesheet" href="../../assets/css/scrolling-nav.css">

                                 and
<link rel="stylesheet" href="{{ URL::asset('css/scrolling-nav.css') }}" />

both way but it shows error on console. my directory structure is as shown in image please help me get out from this problem.

两种方式,但它在控制台上显示错误。我的目录结构如图所示,请帮我解决这个问题。

采纳答案by Hikmat Sijapati

Always place your js/css files in public folder.In your case try like this.Make whole copy of assets folder inside public folder..

始终将您的 js/css 文件放在公用文件夹中。在您的情况下尝试这样。在公用文件夹中制作资产文件夹的整个副本..

For Stylesheet..

对于样式表..

 <link rel="stylesheet" type="text/css" href="{{url('assets/css/bootstrap.min.css')}}"/> 

And For JS file..

而对于 JS 文件..

<script src="{{url('assets/js/components/bootstrap.js')}}"></script>

回答by Alexey Mezenin

Usually you're keeping app assets in resources/assetsdirectory and using Elixirto concatinate, minify and copy assets to a publicdirectory.

通常,您将应用程序资产保存在resources/assets目录中,并使用Elixir将资产合并、缩小和复制到public目录中。

If you're not familiar with Elixir and Gulp, you can just put your assets to a publicdirectory and load them with:

如果你不熟悉 Elixir 和 Gulp,你可以将你的资产放到一个public目录中并加载它们:

<link rel="stylesheet" href="{{ asset('css/scrolling-nav.css' }}">