问题
I spend all day and can't change rich:panel style class. This is the page:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:rich="http://richfaces.org/rich">
<h:head>
<title>Test</title>
<style type="text/css">
.rich-panel{
border: 0px;
background: blue;
}
.rich-panel-body {
border: 0px;
background-color: blue;
color: orange;
font-size: 32px;
}
</style>
</h:head>
<h:body>
<rich:panel>
<p>Hello world!</p>
</rich:panel>
</h:body>
</html>
And the result is the same as without adding style classes.
回答1:
You insert this CSS
<style type="text/css">
div.rich-panel{
border: 0px;
background: blue;
}
div.rich-panel-body {
border: 0px;
background-color: blue;
color: orange;
font-size: 32px;
}
</style>
回答2:
rich panel has attributes Style,Styleclass to attach css
<rich:panel styleClass="somecssclass">
<p>Hello world!</p>
</rich:panel>
or
<rich:panel style="border:0px;color:orange">
<p>Hello world!</p>
</rich:panel>
回答3:
To change style classes of the rich:panel for Richfaces 4.x we must use rf-p, .rf-p-hdr and .rf-p-b classes. For example:
div.rf-p{
border: 5px;
background: blue;
}
div.rf-p-b {
border: 0px;
background-color: blue;
color: orange;
font-size: 32px;
}
回答4:
in your html file do this:
<rich:panel headerClass="panelHeader"
bodyClass="panelBody" >
<f:facet name="header">This is the Header Label</f:facet>
</rich:panel>
your css should look like this:
.panelHeader {
background-image: url();
background-color: #87d6ed;
height: 12px;
text-align: center;
vertical-align: middle;
}
.panelBody {
background-color: #bdf0f0;
height: 8px;
width: 130px;
overflow: auto;
}
来源:https://stackoverflow.com/questions/8095528/richfaces-style-classes-redefinition