【问题标题】:How to apply styles to <h:commandButton> from external CSS in jsf 2.0?如何从 jsf 2.0 中的外部 CSS 将样式应用于 <h:commandButton>?
【发布时间】:2014-05-29 13:36:58
【问题描述】:

我在 JSF 2.0 应用程序中工作,并使用外部样式表进行 UI 样式设置。但我无法通过外部CSS 更改&lt;h:commandButton&gt; 样式。

内联样式也是如此。我还在我的应用程序中使用Richfaces 4.4 皮肤。

【问题讨论】:

  • 注意:今天最新的稳定 RichFaces 版本是 4.3.6.Final。您确定您使用的是 4.4 版吗?

标签: css jsf-2 commandbutton


【解决方案1】:

要在h:commanButton 中应用样式,请使用styleClass 属性:

<h:commandButton value="someName" action="#{bean.method}" styleClass="yourStyle" />

Essential 设置 CSS after RichFaces 样式(例如在模板正文中,而不是在标题中):

<h:body>
    <link rel="stylesheet" type="text/css" href="#{properpath}/your.css" media="all" />
</h:body>

在我的项目中是

<link rel="stylesheet" type="text/css"
    href="#{request.contextPath}/css/basic.css" media="all" />

您可以使用h:outputStylesheet 代替&lt;link /&gt;

【讨论】:

    猜你喜欢
    • 2011-04-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-12-22
    • 1970-01-01
    • 2017-01-06
    • 1970-01-01
    相关资源
    最近更新 更多