更改所选元素树的默认背景颜色

时间:2018-03-14 13:03:25

标签: css primefaces

请帮我改变树中所选元素的默认背景颜色。

xhtml代码是

    <style type="text/css">
        .ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state-highlight
        {
            background-color: green;
        }
    </style>
    <h:head>
    </h:head>
    <h:body>
        <h:form id="mainform">
            <h:panelGrid columns="4" layout="grid">
                <p:outputPanel style="width: 100%; height: 400px">
                    <div id="mainTableDiv">
                        <p:tree id="tree1" value="#{treeDNDView.root1}" var="node" selectionMode="single"
                                selection="#{treeDNDView.selectedNode1}"
                                draggable="true" droppable="true" dragdropScope="demo" scrollable="true"
                                scrollHeight="630" widgetVar="tree1">
                            <p:treeNode>
                                <h:outputText value="#{node}"/>
                            </p:treeNode>
                        </p:tree>
                    </div>
                </p:outputPanel>
......

检查的结果是:

firefox inspection

所选项目的颜色为灰色,但我需要绿色。

1 个答案:

答案 0 :(得分:0)

已添加

.ui-state-highlight,.ui-widget-content .ui-state-highlight,.ui-widget-header .ui-state-highlight**, .ui-tree**

<p:tree id="tree1" value="#{treeDNDView.root1}" var="node" selectionMode="single"
                                selection="#{treeDNDView.selectedNode1}"
                                draggable="true" droppable="true" dragdropScope="demo" scrollable="true"
                                scrollHeight="630" widgetVar="tree1" **styleClass="ui-tree"**>
                            <p:treeNode>
                                <h:outputText value="#{node}"/>
                            </p:treeNode>
                        </p:tree>

消除!重要。