I'm new in Laravel. I started new project with Jetstream, and all goes well excepting one thing: CSS file is empty so auth form is looking rawly.
I got public/css/app.css file with needed style code, but for some reason browser receives it as empty
In layout/app.blade.php is declared:
<link rel="stylesheet" href="{{ mix('css/app.css') }}">
I tried to replace it by:
<link rel="stylesheet" href="{{ asset('css/app.css') }}">
But it is not working. Any ideas? Thank you
Related
so I created a new laravel project and use npm run dev to generate my css file inside public folder.
like my last project i tried to load my CSS like this
<link href="{{ URL::asset('/css/app.css') }}" rel="stylesheet" type="text/css">
but that doesn't work. my folder structure is like this
public
css
app.css
I checked a lot of posts but non of them worked. the only way to load the file is like this
<link href="{{ mix('/css/app.css') }}" rel="stylesheet" type="text/css" >
or
<link href="/css/app.css" rel="stylesheet" type="text/css" >
my question is why asset helper don't work ?
i tried changing the url, changing env 'ASSET_URL', etc
I know this is a really elementary issue, but this question are making me crazy,
btw my last project laravel version was 7 but this one version is 8
Use proper path in laravel asset() helper function.
asset() helper function access from app/public directory.
<link href="{{ asset('css/app.css') }}" rel="stylesheet" type="text/css">
I have a interesting trouble, in my view I have:
<base href="{{asset('')}}" />
<link href="ad/bower_components/bootstrap/dist/css/bootstrap.min.css" rel="stylesheet">
that my css's link , it was long but it still worked a month ago, but now it doesn't work, and I try :
<link href="{{ URL::asset('ad/bower_components/bootstrap/dist/css/bootstrap.min.css') }}" rel="stylesheet">
too, but it haven't worked yet,
but when I try a shorter link, it works normally, so why?
<link href="{{asset('link_to_css_file_in_public_folder')}}" rel="stylesheet" >
That should work.
Ps: put this code in your layouts->app.blade.php or any other layout you use.
in case you want to load separate css file in different pages in your layout call this #yield('styles') and then in your blade import your css file like my sample above inside
#section('styles')
your_code
#endsection
<link rel="stylesheet" href="{{URL::to('/')}}/asset/ad/bower_components/bootstrap/dist/css/bootstrap.min.css">
is your asset folder in public folder or not?..if it then it works
I'm using the knp-snappy-bundle to generate PDF's out of twig.
But my css files are not loading.
I tried it with static url, with absolute url and with only asset url, noting works, but these are the normal css files which I also use when display for example in my edit form. Here are the three options I tried in my pdf.html.twig file
// STATIC DOES NOT WORK
<link rel="stylesheet" href="https://localhost/test/boot.css">
// ASSET DOES NOT WORK
<link rel="stylesheet" href="{{ asset('test/boot.css') }}">
// ABSOLUTE DOES NOT WORK
<link rel="stylesheet" href="{{ absolute_url(asset('test/boot.css')) }}">
Always get this: Warning: Failed to load https://localhost/test/boot.css (ignore)
I presume you are using wkhtmltopdf, in that case you need to use the absolute path to the css file. Not sure what the path is to your web folder, but something like this:
<link rel="stylesheet" href="/var/www/html/Symfony/test/boot.css">
I had this same problem with wkhtmltopdf and had to hard code it like that.
pdf.html.twig file do not extend with another file. Try this code, it works
<link href="{{ app.request.scheme ~'://' ~ app.request.httpHost ~ asset('test/boot.css') }}" rel="stylesheet"/>
As soon as we're in Symfony you could try in TWIG like the following
{% stylesheets
'test/boot.css'
filter='cssrewrite' %}
<link rel="stylesheet" href="{{ asset_url }}"/>
{% endstylesheets %}
Your css file should be reside in your Symfony application web/test directory. Check availability in browser
http://localhost/test/boot.css
Should work
I'm using Laravel 5.2.
I have public/app.css and i link it from views/layouts/app.blade.php with:
<link rel="stylesheet" href="{{ public_path('app.css') }}">
I have tried every combination that i can think of, like using asset() asset_path(), putting app.css in views/layouts/ with the app.blade.php file and nothing will work.
If I inspect the source of a page, it shows the link and the path is correct, but the styles won't apply.
Try this:
<link href="{!! asset('css/app.css') !!}" rel="stylesheet" type="text/css">
Try to use asset() method:
<link rel="stylesheet" href="{{ asset('app.css') }}">
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 ??