将 Bootstrap 主题与 Laravel 集成

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

Integrate Bootstrap theme with Laravel

twitter-bootstraplaravel

提问by Hello Man

I have worked on Laravel and Bootstrap and learnt the basics of both of them. I would like to know how to integrate a Bootstrap theme into the Laravel project so that I can use that for my project. Right now, I have a scratch Laravel folder along with the downloaded theme. How do I proceed with this? I am getting started with some minor projects on Laravel. Appreciate if someone can help me out or link me to videos that show me how to do this.

我曾在 Laravel 和 Bootstrap 上工作过,并学习了它们的基础知识。我想知道如何将 Bootstrap 主题集成到 Laravel 项目中,以便我可以在我的项目中使用它。现在,我有一个临时的 Laravel 文件夹以及下载的主题。我该如何处理?我正在 Laravel 上开始一些小项目。感谢有人可以帮助我或将我链接到向我展示如何执行此操作的视频。

回答by Thomas Van der Veen

You should put your assets (css, js, etc) inside your public folder since files inside that folder should always be accessible to the "public".

您应该将您的资产(css、js 等)放在您的公共文件夹中,因为该文件夹中的文件应该始终可供“公共”访问。

An example project could look like this:

一个示例项目可能如下所示:

Example of bootstrap in laravel

Laravel 中的引导程序示例

Next you can insert these files in your HTML by using hard coded paths like:

接下来,您可以使用硬编码路径将这些文件插入到 HTML 中,例如:

<script src="/path/to/file"></script>

Or you can use the asset()helper function (more preferable):

或者您可以使用asset()辅助函数(更可取):

<script src="<?php echo asset(/path/to/file); ?>"></script>

Hope this was helpful :)

希望这有帮助:)

回答by Isuru Dharmadasa

I have worked on a Laravel project where I had to get a theme from bootswatch.com, Darkly to be specific.

我曾参与过一个 Laravel 项目,我必须从bootswatch.com获取一个主题,具体来说是 Darkly。

I included the theme using a cdn as follows,

我使用 cdn 包含主题,如下所示,

<link href="https://stackpath.bootstrapcdn.com/bootswatch/4.1.0/darkly/bootstrap.min.css" 
      rel="stylesheet"
      integrity="sha384-J01jr7rrJqxij+hUE1E+8N35mlD7L/TMrAO7tOarwMP7AWJM3P/lGXOjt0KLNhtE" 
      crossorigin="anonymous">

But the theme didn't take effect until I removedthe following line which is importing the default css

但是直到我删除了以下正在导入默认 css 的行,主题才生效

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