gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-28 04:42:43 25 4
gpt4 key购买 nike

下午好,我正在尝试从 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/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com