laravel 在laravel项目中放置css文件的位置

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/33988896/
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-08 17:11:08  来源:igfitidea点击:

Where to put css file in laravel project

laravel

提问by Tyler Obier

I have been searching for an answer for this question and with no luck. This is my second day with laravel and im trying to make a custom 404 error page and i dont know to add my css file so i can include it to the document can someone please help me with this.

我一直在寻找这个问题的答案,但没有运气。这是我使用 laravel 的第二天,我正在尝试制作自定义 404 错误页面,但我不知道要添加我的 css 文件,因此我可以将其包含在文档中,有人可以帮我解决这个问题吗?

回答by Covik

Place your css files inside public folder and use link tag in html document (or 404 template)

将您的 css 文件放在 public 文件夹中,并在 html 文档(或 404 模板)中使用链接标签

Example

例子

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

回答by JP Blanco

The best way is using blade syntax with the laravel helper for what you need

最好的方法是在 laravel 助手中使用刀片语法来满足您的需要

<link rel="stylesheet" href="{{ asset('css/style.css') }}">

<link rel="stylesheet" href="{{ asset('css/style.css') }}">

this folder cssor whatever you named it, must be placed inside your public folder.

此文件夹css或任何您命名的文件夹必须放置在您的公用文件夹中。

回答by Abu Bakr

  1. search for Public folder in laravel

  2. Create css folder(That contain stylesheet files of your project), javascript,and Images folder (contain images that you will use in your project).

  1. 在 Laravel 中搜索公共文件夹

  2. 创建 css 文件夹(包含项目的样式表文件)、javascript 和 Images 文件夹(包含您将在项目中使用的图像)。

. Go to layouts in app.blade.php file update html code using blade sintax .

. 转到 app.blade.php 文件中的布局,使用 Blade sintax 更新 html 代码。

<link rel="stylesheet" href="{{ asset('css/style.css') }}">

and JS

和JS

<script src="{{ asset('pickadate/lib/picker.js')}}"></script>