2013-12-10 88 views
1

我創建了一個新的CSS文件的JSF頁面上添加在它下面的樣式:CSS樣式沒有得到應用

.op-label { 
    color: orange; 
} 

我放在這個文件「hms.css」在

「/ webapp/resources」

文件夾。

我已經在我的JSF模板文件BasicTemplate.xhtml如下這包括:

<h:head> 
    <title><ui:insert name="title">Basic Template</ui:insert></title> 
    <h:outputStylesheet name="hms.css"/> 
</h:head> 

這裏是我如何使用這種風格,在我的臉上頁我的輸出組件:

<p:outputLabel value="First Name" styleClass=".op-label"></p:outputLabel> 

問題:樣式不適用於呈現的html。呈現的HTML代碼剪斷它下面:

<head> 

    <link href="/HMSWeb/javax.faces.resource/theme.css.xhtml?ln=primefaces-sunny" rel="stylesheet" type="text/css"></link> 
    <link href="/HMSWeb/javax.faces.resource/hms.css.xhtml" rel="stylesheet" type="text/css"></link> 
    <link href="/HMSWeb/javax.faces.resource/primefaces.css.xhtml?ln=primefaces&v=4.0" rel="stylesheet" type="text/css"></link> 
    <script src="/HMSWeb/javax.faces.resource/jquery/jquery.js.xhtml?ln=primefaces&v=4.0" type="text/javascript"></script> 
    <script src="/HMSWeb/javax.faces.resource/jquery/jquery-plugins.js.xhtml?ln=primefaces&v=4.0" type="text/javascript"></script> 
    <script src="/HMSWeb/javax.faces.resource/primefaces.js.xhtml?ln=primefaces&v=4.0" type="text/javascript"></script> 
    <title> … </title> 

</head> 

問題:是什麼原因呢?任何幫助,將不勝感激。

謝謝!

+2

應該是'styleClass =「op-label」' –

+0

不確定關於jsf,但我不認爲你應該在這裏使用句號'styleClass =「。op-label」' –

+0

@ user876345 ,你的建議奏效了。非常感謝你! – PhantomReference

回答

1

嘗試使用styleClass="op-label"

<p:outputLabel value="First Name" styleClass="op-label"></p:outputLabel> 

,而不是

<p:outputLabel value="First Name" styleClass=".op-label"></p:outputLabel> 
1

正如user876345建議的,刪除期限應該是個訣竅。所以,它應該是這樣的:的

styleClass="op-label" 

代替

styleClass=".op-label"