Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

primefaces with custom css file

Good morning, i have a problem in applying a style sheet on a primefaces commandButton , the button element is as follows:

        <p:commandButton value="Complains" styleClass="styleOrange"/>

and the style sheet:

    .styleOrange {    
    background-color: orange;
}

the css file is placed in the resources folder under css folder:

here's the include statement of the css file:

<h:head>

<h:outputStylesheet name="/resources/css/style.css" library="css" />

</h:head>
like image 419
Eslam Mohamed Mohamed Avatar asked Apr 28 '13 08:04

Eslam Mohamed Mohamed


People also ask

How do I include CSS file in another CSS file?

The @import rule allows you to import a style sheet into another style sheet. The @import rule must be at the top of the document (but after any @charset declaration). The @import rule also supports media queries, so you can allow the import to be media-dependent.

How do I apply a CSS to a specific div?

There is no way to "link a css file to a specific div". You can make the css in style. css apply only to a certain div using selectors, but your question, as stated, makes no sense.

Can I link 2 CSS to HTML?

Yes, It is possible to include one CSS file in another and it can be done multiple times. Also, import multiple CSS files in the main HTML file or in the main CSS file. It can be done by using @import keyword.

How do I link a CSS file to HTML?

CSS can be added to HTML documents in 3 ways: Inline - by using the style attribute inside HTML elements. Internal - by using a <style> element in the <head> section. External - by using a <link> element to link to an external CSS file.


1 Answers

There is no need for the /resources/ prefix. JSF already implicitly loads resources from there.

Just change the name into css/style.css, like this:

<h:outputStylesheet name="css/style.css" />

You should also read this What is the JSF resource library for and how should it be used?

like image 171
Daniel Avatar answered Oct 08 '22 03:10

Daniel