Spring Boot + Thymeleaf embed Tailwind CSS inside HTML for external service? - css

I have a spring boot project and I'm using TailwindCSS. The issue is, while putting
<link rel="stylesheet" type="text/css" th:href="#{~/css/main.css}" />
Works fine when I want to access the HTML file locally from my instance, the issue is I convert these HTMLs into PDFs using API2PDF service.
So, the service is unable to read the CSS and the HTML comes out to be without any styling.
How can I make sure the generated Tailwind CSS is sent along with the URL?

I would include the CSS within the HTML file using the <style> tag

Related

Serving stylesheets from a CDN in a Flask template

I have a simple flask application. It has flask-bootstrap installed and so I can access some CSS classes from there and my own style sheet in my static folder. However, I want to be able to add another stylesheet from a CDN in my index.html file.
I usually do something like place the following inside head tags.:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
Is this possible? I don't think that using the
{{url_for('static' )}}
syntax would work here and I haven't found anything online that's describing what i'm doing (or I couldn't tell).
Yes, this is how I do it too. And then I link to my own stylesheet after the Bootstrap CDN.
Edit: and if you use a base template that is being extended by multiple templates for sub pages you can put the head tag in the base template so it precedes all templates.

Importing contents from 1 html to another html file

Is is possible to import contents from one html file into another by using just plain HTML or CSS? JavaScript or jQuery is NOT an option, I want to be able import contents of a file if JavaScript is disabled
Checkout HTML5 imports via Html5rocks tutorial and at polymer-project
For example:
<head>
<link rel="import" href="/path/to/imports/stuff.html">
</head>
Your best bet is to render the HTML server side, ie, via PHP or server side JS. Since most server readily supports PHP, you can simply change both your HTML file extension to .php and insert a php include tag. (Include PHP file into HTML file).

JSF EL i18n in CSS files

In my html pages I use the Spring message bean like so:
#{ms.my_text_label}
ms is of type ReloadableMessageSourceBundle and will translate my_text_label by looking in some resource bundle files. Can I make it possible to use this in my CSS files as well?
Disclaimer: I'm ignoring the Spring WebFlow part in the question and do as if the JSF project doesn't use any Spring artifacts.
You can just use EL in CSS files the usual way if you load the CSS file via <h:outputStylesheet> instead of plain HTML <link rel="stylesheet">:
<h:outputStylehseet name="some.css" />
Note: this doesn't work for JS files, even not the ones loaded via <h:outputScript>. EL is supported in CSS files for actually only one technical reason: being able to reference CSS background images via #{resource} mapping without the need to hardcode whole library and JSF mapping.
See also:
How to reference CSS / JS / image resource in Facelets template?
How to reference JSF image resource as CSS background image url

How do I use standard GWT CSS style themes from non-GWT pages?

I have written an GWT app and a static Intro page that introduces the app. It is turning out to be convenient for the intro to be a separate .jsp page, rather than part of the app; however, I want the CSS styling to be the same for the app and the intro page. How do I include the same GWT CSS style for the static or .jsp page as for the GWT app?
just include it like a standard webpage like
<link rel="stylesheet" type="text/css" href="{Path to css here}"/>
For instance using the Clean css provided by gwt, defined in projectname.gwt.xml:
<inherits name='com.google.gwt.user.theme.clean.Clean'/>
Your css will be stored in:
/projectname/gwt/clean/clean.css
Is that what you mean?

using css from a library in razor mvc3

I have an mvc 3 razor web application that uses several graphic components from a library.
I have set all the component in the library, I need to add a css file to the library but I dont know how to do it.
so how can I add a css file witch is a library ressource to a cshtml file.
I tried this but it doesnt work:
#section Styles {
<link href="#Url.Content("~/file.css")" />}
add the rel=stylesheet attribute to that link

Resources