【问题标题】:implementing custom css with primefaces 3.1使用 primefaces 3.1 实现自定义 CSS
【发布时间】:2012-05-11 05:07:49
【问题描述】:

我正在使用 Primefaces 3.1,我正在尝试为按钮实现自定义 css。

我的页面定义如下:

<h:head>
<title>Primefaces 3.1</title>
<f:facet name="last">             
    <meta http-equiv="X-UA-Compatible" content="EmulateIE8" /> 
    <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/>                           
    <link type="text/css" rel="stylesheet" href="../resources/Styles/stylesheet.css" />
    <link rel="stylesheet" href="../resources/Styles/pfOverride.css" type="text/css" />
    </f:facet> 
</h:head>

CommandButton 如下所示:

<p:commandButton id="button1" styleClass="custButton"....

pfOverride.css 有以下内容:

.ui-button {
    background-color: #b2f5g3;
    border-color: black;    
}

.ui-button-text {
    background-color: #b2f5g3;
.ui-button-text-only .ui-button-text {
    font-size: 9pt; 
    color: black;
}

而且custButton也设置了不同的值,

我的问题是 pfoverride.css 可以正常工作,但样式表不行。有人可以告诉我我遗漏了什么或做错了什么,我也尝试输入!important,但没有运气。

感谢任何帮助。

【问题讨论】:

    标签: css jsf-2 primefaces


    【解决方案1】:

    如果您将右括号添加到 .ui-button-text 并使用正确的十六进制值(g 不是十六进制数字),这应该可以工作:

    .ui-button-text {
        background-color: #b2f5f3;
    }
    .ui-button-text-only .ui-button-text {
        font-size: 9pt; 
        color: black;
    }
    

    【讨论】:

    • 抱歉打错了,但我说 pfOverride.css 工作正常,但 styleclass.css 中的样式表类 .custButton 不是。如何加载样式表以便我只能使用样式表。看起来它忽略了我的样式表。
    • 我在 IDE 中尝试了代码,它运行良好。唯一的区别是我在页面上直接包含了样式,而不是来自单独的文件。
    • 我不想像上面那样使用 .ui-button-text 类或 .ui-button-text-only .ui-button-text 类,而只使用像 .custCutton 类这样的自定义类从样式表中更改 P:commandButton 的外观和感觉,这可能吗?
    猜你喜欢
    • 2013-05-05
    • 2012-10-11
    • 1970-01-01
    • 2013-04-22
    • 1970-01-01
    • 2012-02-04
    • 2023-04-04
    相关资源
    最近更新 更多