The style
property is rather useless on <p:selectOneMenu>
. Look at the generated HTML output by rightclick View Source or Inspect Element. It would be applied on the wrapper div, not on the concrete item, let alone the list. To style the selected item, you need to select the .ui-selectonemenu-label
child of the menu via styleClass
attribute . To style the list, you need to select the .ui-selectonemenu-list
child of the panel (the dropdown) via panelStyleClass
attribute.
So, all with all, this should do:
<p:selectOneMenu styleClass="menu" panelStyleClass="panel">
With
.menu .ui-selectonemenu-label {
background: pink;
}
.panel .ui-selectonemenu-list {
background: pink;
}
Make sure that the CSS is initialized/loaded after PrimeFaces own styles. Best is to declare it in a .css
file which is included by a <h:outputStylesheet>
in the <h:body>
.
See also: