Adding Css file - php

laravel 4.2: my demo project in ytform when i try to add css file (style.css) from public folder having another folder, css folder. try to get any class its not working .
in View: i have an other folder, name layouts and i am accessing here css file but not working?
where in master.blade.php
<head>
#section('head')
<meta charset="UTF-8">
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css">
<link rel="stylesheet" type="text/css" href="/css/style.css">
#show
</head>
i try with given both ways but in vain, css file not supporting in any view folder files how add css files
<link rel="stylesheet" type="text/css" href="/css/style.css">
{{HTML::style('css/style.css')}}
any solution or mistake ?

<link rel="stylesheet" type="text/css" href="{{ asset('css/style.css') }}">
You can try this
or
{{ HTML::style(asset('css/site.css'), array('rel' => 'stylesheet', 'type' => 'text/css')) }}
and the css files needs to be in the public folder for this to work

Just include some lines in Blade template
{{ HTML::style('css/main.css') }}
See here as a reference

Related

Laravel CSS and Bootstrap doesn't working

I created a new Laravel project and downloaded the bootstrap CSS and JS files and put the CSS file in resources/css and the JS files of bootstrap and popper and jQuery in resources/js and in the welcome.blade.php I linked the CSS file and the JS files like this
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Osama The Coder</title>
<link rel="stylesheet" href="{{ asset('css/bootstrap.min.css') }}">
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
</head>
<body>
<section class="text-danger">
Hello World
</section>
<script src="{{ asset('js/jquery-3.6.0.min.js') }}"></script>
<script src="{{ asset('js/popper.min.js') }}"></script>
<script src="{{ asset('js/bootstrap.min.js') }}"></script>
</body>
</html>
when I opened the project it was just the text without any styles or Bootstrap font-family
even when I linked the app.css and applied color red to the section element I doesn't see any changes
Please follow the following steps
Put all your static assets in public directory
Organize your assets in different folders e.g public/js for js related files and public/css for css related files
Then access your files using the helper method like below
<link rel="stylesheet" href="{{ asset('css/bootstrap.min.css') }}">
/* or js files */
<script src="{{ asset('js/jquery-3.6.0.min.js') }}"></script>

Referencing local folders into head laravel

Im including custom bootstrap folder & css into laravel index, but none ofmy tries works, appreciate help of how to make it.
i have placed the folders in public folder of lavarel
<link href="css/StyleSheet_landingPage.css" rel="stylesheet">
<link href="Content/font-awesome.min.css" rel="stylesheet" />
Root order
As #Harven suggested in the comments, you should read up on using the asset helper method with Laravel.
Assuming your stylesheet lives at the following:
Laravel/public/css/StyleSheet_landingPage.css
Then this will work.
<link href="{{ asset('css/StyleSheet_landingPage.css') }}" rel="stylesheet" type="text/css" >
Try maybe just like here:
<link href="/css/StyleSheet_landingPage.css" rel="stylesheet">
<link href="/Content/font-awesome.min.css" rel="stylesheet" />

How to Add External CSS in Laravel 5.4

I am new in Laravel...
web.php
<?php
Route::get('/', function () {
return view('method1.home');
});
home.blade.php
#extends('dashboard')
dashboard.blade.php
<!DOCTYPE html>
<html class="no-js">
<head>
#include('includes.head')
</head>
<body>
do something...
</body>
head.blade.php
<link rel="stylesheet" href="{{ URL::asset('front_view/css/main.css') }}">
<link rel="stylesheet" href="{{ URL::asset('front_view/css/shop.css') }}">
<script src="{{ asset('front_view/js/vendor/modernizr-2.6.2.min.js') }}"></script>
The path and folder name is correct.
But the CSS is not working.
open or create file if not exist constants.php inside config folder and then add this line inside that file
define('SITE_PATH', 'http://localhost:8000/'); // write here you site url
and then use like this in view
<link rel="stylesheet" type="text/css" href="<?php echo SITE_PATH; ?>css/custom.css">
it will search for custom.css inside public/css folder so create css folder inside public folder and the create your custom.css or create directly inside you public folder

Route view don't load CSS Laravel

The CSS don't load em some routes, example, a route with a var:
//LINK
Route::get('/link/{id}', 'PagesController#link');
TEMPLATE:
<link rel="stylesheet" href="../public/css/style.css">,
How I can fix it?
To generate URL's for assets like CSS/JS/images/etc., in Laravel, use the helper function asset, instead of specifying the relative URL:
<link rel="stylesheet" href="{{ asset('css/style.css') }}">
See the documentation
<link rel="stylesheet" href="{{ asset('public/css/style.css') }} ">
or
<link rel="stylesheet" href="{{ asset('css/style.css') }} ">
Use absolute paths like this (starting from the end of 'public'):
<link rel="stylesheet" href="/css/style.css">,
The right solution is the following one:
<link rel="stylesheet" href="/css/style.css">
Don't forget to add the / before the css/style.css or it wont load.

Can't load CSS in Laravel

Hi I am currently learning Laravel and seem to be having issues loading custom CSS that is located in the public/css/bootstrap.css.
I have been attempting to load it via
<link href="{{ asset('css/bootstrap.css') }}" rel="stylesheet" type="text/css" >
But it is if the CSS is not getting picked up. When I view the page source (http://portfollo.co.uk/css/bootstrap.css) I just get an error. Any ideas ?
Try with public/css/bootstrap.css
<link href="{{ asset('public/css/bootstrap.css') }}" rel="stylesheet" type="text/css" >
OR
<link href="'/css/bootstrap.css'" rel="stylesheet" type="text/css" >
You should put your css file inside public folder, (app/public):
then in your head:
<link rel="stylesheet" href="{{ url('/') }}/style.css" type="text/css"/>
Public folder will contain all css and js files, you can also create assets folder inside public folder and then point to correct path:
<link rel="stylesheet" href="{{ url('/') }}/assets/css/style.css" type="text/css"/>
change name as public/css/bootstrap.css and put css in that folder. and give the same path.
This is not a CSS error. its Routing error. check your route.php file just check your source code like this view-source:http://portfollo.co.uk/css/bootstrap.css
you are trying something wrong ??

Categories