I have a <p:menubar>
with some <p:menuitem>
s to display a horizontal menu to users. This is my current simplified code (removed internationalization and other non-related stuff):
<p:menubar id="mbrMainMenu" styleClass="centeredMenuBar">
<p:menuitem value="Home" outcome="/index.xhtml" />
<p:submenu label="Product Catalog">
<!-- some menuitems here... -->
</p:submenu>
<p:submenu label="Make your own design">
<!-- some menuitems here... -->
</p:submenu>
</p:menubar>
Code above gets displayed like this:
_____________________________________________________ _____________________________________
| | | | |
| Home | Product Catalog | Make your own design | <wasted whitespace> |
|________|___________________|________________________|_____________________________________|
I'm searching for a look n' feel where the <p:menuitem>
and <p:submenu>
are centered and the width of each one is distributed accordingly (I'm not very skilled with CSS):
_______________________________________________________________________________
| | | |
| Home | Product Catalog | Make your own design |
|__________________|___________________________|________________________________|
I've found how to center them using a custom CSS centeredMenuBar
(taken from here: How to centralize primefaces menubar?), but now I'm having a hard time trying to distribute the menu items along the menu bar, they are all stick.
__________________________________________________________________ ____________
| | | | | |
| <wasted> | Home | Product Catalog | Make your own design | <wasted> |
|____________|________|___________________|________________________|____________|
I've tried this but failed:
Creating a custom CSS to override the ui-menu-item and ui-menu-parent PrimeFaces styles:
.ui-menu-item .ui-menu-parent { width: auto; }
Using
style="width: auto;"
directly in the<p:menuitem>
and<p:submenu>
.
Any idea how to accomplish this?
This is what I have:
This is what I want (last picture edited in paint just to show the last form):