'CSS file not imported in laravel blade view
I am trying to import a CSS file into one of my Laravel views but it's not being included for some reason.
This is is what I have in my view file:
@extends('layouts.admin')
@section('style')
<link href="{{asset('public/css/my-css-file.css')}}" rel="stylesheet"/>
@endsection
@section('content')
<div class="content">view content.....</div>
@endsection
If I include my css file in layout file it works fine but I want it applied to one view only. Any help please? Thanks.
Solution 1:[1]
@yield('content')
yields the content of @section('content')
so you need to do the same for your @section('style')
:
Replace @section('style')
in your layout file with @yield('style')
.
Solution 2:[2]
When I need to aply style in a view or some components, I use to do this:
@section('css')
-- your awesome styles here --
@stop
If Your styles code is not too long, maybe You can copy and paste It inside.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | brombeer |
Solution 2 | German_Kast |