Css Files Are Not Loading in Laravel View

CSS files are not loading in Laravel view

The CSS files not loading is related to an error in the file path. You forgot the css folder inside the bootstrap-* folder

{{ asset('assets/bootstrap-4.1.3/css/bootstrap.min.css') }}

The error shown in the screenshot is more related to a view not being found or an url/ route not defined.

Why my css file is not loading in laravel?

You're trying to access the resources folder, which is not exposed to the public, you'll have to compile your css so it lives in the public folder, which is the folder that anyone(including your frontend) can access using https://your-url.tld/{public file path}. There are 2 ways in which you can have your user.css file available for to your frontend:

One:

You can import your user.css file to the existing resources/css/app.css file:

/* app.css file */
@import "../path/to/user.css";

Two:

You can compile user.css to a separate file, in case you want to use that file specifically on another layout or blade file instead of mixing it globally with the app.css file:

// webpack.mix.js file
mix.js('...')
.css('resources/css/user.css', 'public/css');

Then in your layout file:

// app.blade.php file
<link rel="stylesheet" href="{{ asset('css/user.css') }}">

Hope it helps.

Laravel 5 not finding css files

Use this to add assets like css, javascript, images.. into blade file.

FOR CSS,

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

OR

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

FOR JS,

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

OR

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

FOR IMAGES,

{{ asset('img/photo.jpg'); }}

Here is the DOC

Alternatively, if you pulled the composer package illuminate/html which was come as default in laravel 4.2 then you can use like below, In laravel 5. you have to manually pull the package.

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

Here is an Example.

My css files are not running inside my .blade.php file

Try configuring the assets url in the .env file. ASSET_URL=http://localhost/assets/. Then do {{asset('css/header.css')}}

CSS files and images are not loading in mobile browser Laravel

So, the problem is with the URL. If you try to open http://gahancollections.com it won't work. Notice that the URL is without www. And, now if you open http://www.gahancollections.com in your browser it will work. So, the problem should be in your routes/web.php file.

Kindly, add your routes/web.php file contents so that we can answer accurately.



Related Topics



Leave a reply



Submit