使用{{HTML}}的Laravel 4 css和javascript链接

vik*_*imt 2 laravel laravel-4

我是Laravel 4的初学者,我使用HTML类包含css文件,但是它没有用,所以请帮助我.我的代码是: -

在视图中: - model_window.php

<?php HTML::style('css/style.css'); ?>

<a href="#openModal"><input  type="submit" value="show" name=""show_button></a>

<div id="openModal" class="modalDialog">
   <div>
      <a href="#close" title="Close" class="close">X</a>
      <h2>Modal Box</h2>

   </div>
</div>
Run Code Online (Sandbox Code Playgroud)

我的css文件: - 在公共场合 - > css - > style.css

.modalDialog:target {
                  opacity:1;
                  pointer-events: auto;
                   }

     .modalDialog > div {
                width: 400px;
                position: relative;
                margin: 10% auto;
                padding: 5px 20px 13px 20px;
                border-radius: 10px;
                background: #fff;
                background: -moz-linear-gradient(#fff, #999);
                background: -webkit-linear-gradient(#fff, #999);
                background: -o-linear-gradient(#fff, #999);
                 }
Run Code Online (Sandbox Code Playgroud)

Dol*_*rma 6

你可以将你的文件重命名为index.blade.php,其中第二个必须有刀片,你可以简单地使用:

    {{ HTML::style('public/css/index.css') }}
    {{ HTML::script('public/js/jquery.pnotify.min.js') }}
Run Code Online (Sandbox Code Playgroud)

  • 我不认为`public`文件夹应该在这里.相反,Laravel的`public`文件夹应该是web根目录.你应该使用`{{HTML :: style('css/index.css')}}`来引用资源. (2认同)

Dol*_*rma 5

你必须将文件放入公共目录,然后才能轻松使用

<?php echo HTML::style('css/style.css'); ?>
Run Code Online (Sandbox Code Playgroud)