when i add my css file to laravel project it does not work
why this file make laravel project does not work
and when i remove it form the project it work correctly
I put the css ,images ,and js into public folder
and html into resources folder and use this to require the files
<link rel="stylesheet" href="{{Request::root()}}/webSite/style.css"/>
when i inspect element in browser there is no error
is that correct in css file ?
background-image: url(images/Overlay/1.jpg);
Use this instead
<link rel="stylesheet" href="{{asset('webSite/style.css')}}"/>
asset function returns the path of the public folder with parameter path appended
Related
I tried to link a css to html in laravel and link an image (both css and image are in public folder) but it does not work. I tried using asset and url but it does not work either. I don't understand what is wrong. This is how I wrote the link:
<link rel="stylesheet" href="/css/styles.css">
<img src="/img/logo-kitsune-dojo.jpg" alt="logo kitsune dojo">
I have already tried asset and url. They don't work. I want mi css and my imagen to link.
use asset() function generates a URL
<link rel="stylesheet" type="text/css" href="{{ asset('css/styles.css') }}">
<img src="{{ asset('img/logo-kitsune-dojo.jpg') }}" alt="logo kitsune dojo">
In Laravel, you can use asset() helper function to link assets like CSS and images:
<link rel="stylesheet" href="{{ asset('css/styles.css') }}">
<img src="{{ asset('img/logo-kitsune-dojo.jpg') }}" alt="logo kitsune dojo">
Make sure that the assets path is correct and that the files are in the public directory of the project.
You may solve this problem by using asset() helper function
For css link: If your css exist in public folder folowing this directory you may use this
For Image: If your image exist in public folder folowing this directory you may use this
**To link a CSS page in Laravel, you can follow these steps:
1Create a CSS file in the public folder of your Laravel project. For example, you can create a file named style.css in the public/css folder.
2In your HTML file, add a link to the CSS file in the head section. You can use the asset function provided by Laravel to generate the URL to your CSS file.**
<head>
<link rel="stylesheet" href="{{ asset('css/style.css') }}">
</head>
**3.Make sure that the URL generated by the asset function is correct. The URL should start with the base URL of your Laravel application, which is usually the root directory of your project.
That's it! Your CSS file should now be linked to your HTML file, and the styles defined in your CSS file should be applied to your HTML content.**
**To add an image to a web page in Laravel, you can follow these steps:
1 Place the image file in the public folder of your Laravel project. For example, you can create a folder named images in the public folder and place your image file in it.
2 In your HTML file, use the img tag to display the image. You can use the asset function provided by Laravel to generate the URL to your image file.**
<img src="{{ asset('images/image_name.jpg') }}" alt="Image description">
**4 Replace image_name.jpg with the name of your image file.
5 Make sure that the URL generated by the asset function is correct. The URL should start with the base URL of your Laravel application, which is usually the root directory of your project.
That's it! Your image should now be displayed on your web page.**
I want to apply margin-bottom on #createNewBook, I added a CSS file in laravel by using <link rel="stylesheet" href="/assets/css/style.css">. But it's not working. Can anyone tell me how to add a CSS file to my laravel project?
This is my HTML code in laravel:
This is CSS code:
This is my directory format:
And this is the output:
Put the assets folder in public then in the blade file use this syntax to load css
{{asset('assets/css/style.css')}}
You have to put your assets folder into the public folder because only the things in the public folder are accessible publicly.
And then in the blade.php file use the following syntax to load CSS.
<link rel="stylesheet" href="{{asset('assets/css/style.css')}}">
I am trying to load css, js and images files kept inside my public/css/assests folder. Link which i have been giving is
<link rel="stylesheet" href="/public/css/assets/js/jquery-ui/css/no-theme/jquery-ui-1.10.3.custom.min.css">
But when i open my page in browser it gives error that is
GET http://localhost:8000/public/css/assets/js/jquery-ui/css/no-theme/jquery-ui-1.10.3.custom.min.css net::ERR_ABORTED
Please tell me what to do to resolve the error.
you can use asset() to load css and js and images from public folders.asset will point to public folder
<link rel="stylesheet" href="{{asset('css/assets/js/jquery-ui/css/no-theme/jquery-ui-1.10.3.custom.min.css')}}">
asset()
asset() will generate a URL for an asset using the current scheme of the request (HTTP or HTTPS):
please use asset() function
<link rel="stylesheet" href="<?php echo asset('css/assets/js/jquery-ui/css/no-theme/jquery-ui-1.10.3.custom.min.css'); ?>">
asset() gives full url of your root directory
/ points to public folder by default, so remove /public
<link rel="stylesheet" href="/css/assets/js/jquery-ui/css/no-theme/jquery-ui-1.10.3.custom.min.css">
I am trying to update existing css file but file is not updating, seems phpfox is generating cache. Then I tried to add another css file in template.html.php using following code..
<link rel="stylesheet" type="text/css" href="{param var='core.path'}theme/frontend/freedawn/style/default/css/cus_style.css" />
Html file gets updated but displays error "CSS file not found."
How to add/ update css/js file in PHPFox?
set version number at the end of file for getting a current version.
<link rel="stylesheet" type="text/css" href="style.css?1"/>
Have you tried to clear the cache in Maintenance / Cache Manager? If you modified controller and assets, such as CSS, most probably site will display old cached data and you won't be able to locate your changes.
<link href="/app/app.css" rel="stylesheet" type="text/css">
The above is the code I'm using to access a stylesheet, but it's not working at the .
Some extra details:
This is in a .php file, but it's located within the head of an html section
I'm working on a temporary url (i.e. 'my.ipa.dd.res/mydomain.com/dir/'). This might be the reason it's not working.
Edit:
It's a stylesheet I'd like to use on several pages, which is why I'm trying to point to a root directory (so that I don't need the file in every single folder I create).
Well I think you need to store your root directory path as a string to include your css file with an absolute URL.
Something like :
<link href="{$absoluteRootPath}/css/styles.css" rel="stylesheet" type="text/css">
If you remove the leading slash it will look for the css file in the folder relative to the current.
<link href="app/app.css" rel="stylesheet" type="text/css">
Edit: to reuse in multiple scripts in different dirs you would need to specify an absolute path, so to avoid having to change it in multiple places when you go live (ie stop using the temporary url) you should define a variable.
<?php
// set absolute path to the stylesheet
$cssPath = 'http://my.ipa.dd.res/mydomain.com/dir/';
?>
And
<link href="<?php echo $cssPath; ?>app/app.css" rel="stylesheet" type="text/css">
Depending on your php architecture you may need to define $cssPath as a global or you may be able to add it to an existing config variable. This is completely dependent on your framework.
I've been having this same problem recently. Here's what worked for me
Now on the index page, replace link rel="/app/app.css" href="stylesheet" type="text/css"
with
?php include 'style.php' ?
And on the style.php page insert the following tags:
style and /style
You can put the regular CSS between those two tags. See if that works. BTW for some reason I can't insert the greater or less than symbols without making the code disappear... Forgive me, I'm new here..