Laravel snappy - How to Load internal/external css

浪子不回头ぞ 提交于 2021-01-27 13:41:43

问题


I am trying to get the css styling working for my pdf documents. So far no such luck.

  1. 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

  2. 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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!