duanhuang1699 2015-07-30 14:17
浏览 162
已采纳

Laravel 5:添加自定义样式/脚本

This is kind of a stupid question, and I've looked around for similar answers and found some, however they are a bit more specific than what I am asking.

Say I want to include a custom styles.css or scripts.js file, would I just create a css/js folder in resources/views folder, and then call to them in my blade.php files like I would normally do in an HTML file when not using Laravel?

Example: <link type="text/css" rel="stylesheet" href="css/styles.css">

Or is there a different approach to this in Laravel?

  • 写回答

2条回答 默认 最新

  • dsg56465 2015-07-30 14:31
    关注

    Put your css files into the public folder like public/css/styles.css

    Use the asset() function to add css, javascript or images into your blade template.

    For Style Sheets

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

    or

    <link href="{{ URL::asset('css/styles.css') }}" rel="stylesheet" type="text/css" >
    

    For Javascript

    <script type="text/javascript" src="{{ asset('js/scripts.js') }}"></script>
    

    or

     <script type="text/javascript" src="{{ URL::asset('js/scripts.js') }}"></script>
    

    You may also be interested to have a look at Laravel's Elixir to process your styles and javascript.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 Chatgpt被封号以后,换用apple和gmail注册失败,直接跳转封号界面
  • ¥15 这几个有点疑问解答一下
  • ¥20 vb.net读写.mdb文件
  • ¥15 r语言如何绘制这样的降水地图
  • ¥15 服务器一块硬盘重启过程中安装后,硬盘不识别了怎么修复?
  • ¥15 怎么实现微信红包不拆包
  • ¥15 0基础学机器人运动控制要多久?
  • ¥15 .net core 怎么进行中英文转换
  • ¥15 数学的三元一次方程求解
  • ¥20 iqoo11 如何下载安装工程模式