php - 从 View 中的公用文件夹调用 CSS。拉维尔 5.3

标签 php html css view laravel-5.3

下午好,我正在尝试从 View 文件 (create.blade.php) 调用 css 我一直在尝试很多方法,比如调用:

{{ HTML::style('css.section') }}

而且结果总是一样的,找不到 HTML 类。 (我安装了它但是是旧版本) 或者 View 是 Bootstrap 样式的默认 View 。 我只想要一个干净的代码,因为有一个 表单内的样式标签。

这是我的 CSS。来自“public/css/section.css”

<style>
    section {
        font-family: 'Lato';
        background-size: 2000px;
        background-repeat: no-repeat;
        border-radius: 5px;
        width: 50%;
        margin: 0px auto;
        float: none;
    }
</style>

这是我的众多观点之一,您可以在其中看到样式标签看起来有多糟糕:

@extends('admin.template.main')

@section('title' , 'Listado de negocios')

@section('content')

<style>
    section {
        font-family: 'Lato';
        background-size: 2000px;
        background-repeat: no-repeat;
        border-radius: 5px;
        width: 50%;
        margin: 0px auto;
        float: none;
        }
</style>

    <a href="{{ route('admin.stores.create') }}" class="btn btn-info">Agregar negocio</a><hr>
    <table class="table table-striped">
        <thead>
            <th>ID</th>
            <th>Icono</th>
            <th>Nombre</th>
            <th>Accion</th>
        </thead>
        <tbody>
            @foreach($stores as $store)
                <tr>
                    <td>{{ $store->id }}</td>
                    <td><img class="thumbnail" src="/icon/stores/{{$store->id}}/{{ $store->icon }}" width="200" height="150"></td>
                    <td>{{ $store->name }}</td>
                    <td>
                        <a href="{{ route('admin.stores.destroy', $store->id) }}" class="btn btn-danger"><span class="glyphicon glyphicon-trash" onclick="return confirm('Seguro que deseas eliminar este negocio?')" aria-hidden="true"></span></a>
                        <a href="{{ route('admin.stores.edit', $store->id) }}" class="btn btn-warning"><span class="glyphicon glyphicon-wrench" aria-hidden="true"></span></a>
                    </td>
                </tr>
            @endforeach
        </tbody>
    </table>

@endsection

希望你能帮帮我。

最佳答案

HTML 类已从 Laravel 框架 > 版本 5 的 Illuminate 包中删除。

要使其正常工作,您可以这样做:

将此添加到您的 composer.json

"illuminate/html": "5.*"

然后运行

composer update

app.php 的 providers 数组下,添加这一行

Illuminate\Html\HtmlServiceProvider::class,

并将这些添加到别名数组下:

'Form'      => Illuminate\Html\FormFacade::class,
'Html'      => Illuminate\Html\HtmlFacade::class,

现在您可以像这样在 Blade View 中使用 HTML 类了。

{!! HTML::style('assets/css/css.section.css') !!}

希望这对您有所帮助!

关于php - 从 View 中的公用文件夹调用 CSS。拉维尔 5.3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41124079/

相关文章:

php - 如何递归构建树深度未知的 <select>

php 和 session 重定向错误

php - 使用 php file_get_content 函数发送参数

Javascript 在点击元素下显示

javascript - 淡入淡出链接悬停不起作用

php - 将 $_GET 和 $_POST 分配给单个变量

javascript - 悬停时颜色变化

html - 在 div 中使用选中的选择器

javascript - 样式表干扰

css - 为什么针对 1024x768 的媒体查询也针对具有视网膜显示屏的 iPad?