在Laravel 4中使用Bootstrap的最佳方法 [英] Best method to use Bootstrap in Laravel 4

查看:84
本文介绍了在Laravel 4中使用Bootstrap的最佳方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在正在使用Laravel 4,
在我的网站上使用引导程序的最佳方法是什么?
有什么需要更改的东西吗?我应该在哪里放置css文件?

I am using now Laravel 4,
What is the best method to use bootstrap for my site?
Is there some stuff I need to change and where do I put the css files?

有人说我需要使用composer,另一个人说我需要使用artisan

Someone said that I need to use the composer and another said that I need to use the artisan

谢谢

推荐答案

关于Laravel您必须了解的一些事情:

Some things you must know about Laravel:

它与您的前端没有任何关系,包括Twitter Bootstrap.

放置文件的位置完全由您决定,但公用文件夹通常位于公用可见文件必须存放的位置.

CSS和JavaScript文件是由浏览器直接下载的,因此这些文件应位于您的公用文件夹中.

CSS and JavaScript files are directly downloaded by browser, so those files should be in your public folder.

要下载/使用Bootstrap,您可以选择以下选项:

To download/use Bootstrap you have some options:

1)转到 http://getbootstrap.com/并下载.

1) Go to http://getbootstrap.com/ and download it.

2)使用凉亭( https://github.com/bower/bower )为您下载.

2) Use bower (https://github.com/bower/bower) to download it for you.

3)如果您打算使用Bootstrap模板,通常是那些Bootstrap附带的模板.

4)使用CDN,例如 http://www.bootstrapcdn.com/

4) Use a CDN, like http://www.bootstrapcdn.com/

我个人使用Bower,可以按照以下步骤安装和使用它:

I, personally, use bower, those are the steps you can follow to install and use it:

安装

[sudo] npm install bower

在项目目录中创建一个.bowerrc文件,该文件会告诉bower在哪里下载软件包:

Create a .bowerrc file in your project dir, which tells bower where to download your packages:

{
    "directory": "public/bower"
}

创建一个bower.json文件,其中包含已安装的软件包:

Create a bower.json file, which holds your installed packages:

{
  "name": "YourApp.com",
  "dependencies": {
  }
}

然后,您只需要使用它来安装软件包:

Then you just need to install your packages using it:

bower install bootstrap -S
bower install jquery -S

您还可以使用它来查找软件包

And you can also use it to find packages

bower search google-code-prettify

安装引导程序后,您的css文件将位于:

After installing bootstrap, your css files would be located at:

public/bower/bootstrap/dist/css/

在Laravel中,有很多方法可以包含资产,这是其中之一,在查看编译器时使用Blade:

In Laravel there are many ways of including your assets, this is one of those, using Blade as you view compiler:

<link href="{{ asset('bower/bootstrap/dist/css/bootstrap.min.css') }}" rel="stylesheet">

这篇关于在Laravel 4中使用Bootstrap的最佳方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆