如何在包含artisan的laravel 5中包含CSS? [英] How to include CSS in laravel 5 running with artisan?
问题描述
我是Laravel的新手,正在尝试让公共目录中的css加载。该页面加载没有问题,但CSS给了我一个404错误的firebug:
NetworkError:404 Not Found - http:/ /127.0.0.1:8000/css/main.css
我在刀片模板中写道:
< link href ={{asset('/ css / main.css')}} =stylesheet >
以下输出:
< link href =http://127.0.0.1:8000/css/main.css =stylesheet>
这似乎是正确的。
使用php工匠服务运行。有什么建议么?
试试:
< link href ={{asset('css / main.css')}} =stylesheet> $ bOR
< link href ={{url('css / main.css')}} =stylesheet>
OR
如果您使用 php artisan serve 有可能您的公用文件夹没有被使用,所以请使用PHP本地服务器,并将公共文件夹指定为Web根目录。
停止 artisan serve
并尝试使用PHP本地服务器,方法是在您的Laravel项目的根目录下执行以下命令: php -S localhost:8000 -t public
I am new to Laravel and am trying to get the css in the public directory to load. The page loads no problem but the CSS gives me a 404 error in firebug:
"NetworkError: 404 Not Found - http://127.0.0.1:8000/css/main.css"
I wrote this in the blade template:
<link href="{{ asset('/css/main.css') }}" rel="stylesheet">
Which outputs:
<link href="http://127.0.0.1:8000/css/main.css" rel="stylesheet">
Which seems correct.
The site is run with php artisan serve. Any suggestions? Thanks!
Try:
<link href="{{asset('css/main.css')}}" rel="stylesheet">
OR
<link href="{{url('css/main.css')}}" rel="stylesheet">
OR
If you are using php artisan serve its possible that your public folder is not being used, so use PHP native server instead and specify the public folder as the web root.
Stop artisan serve
and try using PHP native server by issuing this command at the root of your Laravel project: php -S localhost:8000 -t public
这篇关于如何在包含artisan的laravel 5中包含CSS?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!