带有自定义 css 文件的 primefaces
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16261039/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
primefaces with custom css file
提问by Java Player
Good morning, i have a problem in applying a style sheet on a primefaces commandButton
, the button element is as follows:
早上好,我在primefaces上应用样式表时遇到问题commandButton
,按钮元素如下:
<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:
css文件放在css文件夹下的resources文件夹中:
here's the include statement of the css file:
这是css文件的include语句:
<h:head>
<h:outputStylesheet name="/resources/css/style.css" library="css" />
</h:head>
回答by Daniel
There is no need for the /resources/
prefix. JSF already implicitly loads resources from there.
不需要/resources/
前缀。JSF 已经从那里隐式加载资源。
Just change the name into css/style.css
, like this:
只需将名称更改为css/style.css
,如下所示:
<h:outputStylesheet name="css/style.css" />
You should also read this What is the JSF resource library for and how should it be used?
您还应该阅读这篇JSF 资源库的用途是什么,应该如何使用它?
回答by Thangnv
U must edit path of css file:
你必须编辑 css 文件的路径:
<h:outputStylesheet library="css" name="#{request.contextPath}/css/style.css"/>