douchun3680 2018-07-16 11:52
浏览 88

如何在Laravel 5.4中添加外部CSS

I am new in Laravel...

web.php

<?php

Route::get('/', function () {
    return view('method1.home');
});

home.blade.php

@extends('dashboard')

dashboard.blade.php

<!DOCTYPE html>
<html class="no-js">
<head>
    @include('includes.head')
</head>

<body>
do something...
</body>

head.blade.php

<link rel="stylesheet" href="{{ URL::asset('front_view/css/main.css') }}">
<link rel="stylesheet" href="{{ URL::asset('front_view/css/shop.css') }}">
<script src="{{ asset('front_view/js/vendor/modernizr-2.6.2.min.js') }}"></script>

The path and folder name is correct.

But the CSS is not working.

  • 写回答

1条回答 默认 最新

  • duai8153 2018-07-16 12:10
    关注

    open or create file if not exist constants.php inside config folder and then add this line inside that file

    define('SITE_PATH', 'http://localhost:8000/'); // write here you site url
    

    and then use like this in view

    <link rel="stylesheet" type="text/css" href="<?php echo SITE_PATH; ?>css/custom.css">
    

    it will search for custom.css inside public/css folder so create css folder inside public folder and the create your custom.css or create directly inside you public folder

    评论

报告相同问题?

悬赏问题

  • ¥15 MATLAB运行显示错误,如何解决?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 UE5#if WITH_EDITOR导致打包的功能不可用
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?
  • ¥15 电磁场的matlab仿真
  • ¥15 mars2d在vue3中的引入问题
  • ¥50 h5唤醒支付宝并跳转至向小荷包转账界面
  • ¥15 算法题:数的划分,用记忆化DFS做WA求调