问题
I am trying to get the css styling working for my pdf documents. So far no such luck.
Is it possible to use CDN style sheet documents? When I add say bootstrap stylesheet cdn to my view's head section, I get the error below;
The exit status code '1' says something went wrong: stderr: "Loading pages (1/6) [> ] 0% [======> ] 10% [======> ] 11% Error: Failed to load https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css, with network status code 3 and http status code 0 - Host not found
I tried adding the entire bootstrap file inline, in that case, there is no error but it seems flexbox is not working at all. Only styling of text properties (font background color etc) changed.
What am I missing here? Ideally, I use tailwindcss on my app, Is it possible for me to use that? If so, How could I do that?
回答1:
You need to give directory path instead of url path for external css, so if your css file is in public/css directory path
instead of using
<link rel="stylesheet" href="{{ asset('css\style.css') }}" media="all" />
you need to use
<link rel="stylesheet" href="{{ public_path('css\style.css') }}" media="all" />
回答2:
(Laravel - Lumen)
helpers.php got paths : resource_path(), database_path(), base_path(), storage_path()
.
Use resource
path where the blade
files also included. (easy to manage)
<link rel="stylesheet" href="{{ resource_path('views/pdf/invoice/css/styles.css') }}" media="all" />
This will link styles.css
file in the resource/views/pdf/invoice/css/
folder path.
来源:https://stackoverflow.com/questions/55207614/laravel-snappy-how-to-load-internal-external-css