16

How do I align the content in the columns created by panelGrid component to the top ?

I tried with no success, the following code

<h:panelGrid columns="2" style="vertical-align:top;  " >
       <p:tabView style="margin:0px 0px 50px 0px; width: 450px; padding-top: 0px;vertical-align:top" ></p:tabView>                
       <p:menubar autoSubmenuDisplay="true" style="width: 300px; vertical-align:top" ></p:menubar>
</h:panelGrid>

But the 2 columns created hereby still remain vertically middle aligned.

Rajat Gupta
  • 25,853
  • 63
  • 179
  • 294

2 Answers2

24

Based on this answer, you can do like this (I like this approach the most)

<h:panelGrid columnClasses="className">

.className {
    vertical-align: top;
}
Community
  • 1
  • 1
Dejell
  • 13,947
  • 40
  • 146
  • 229
16

for me it works if you do it like that:

<h:panelGrid columns="6" cellspacing="4" cellpadding="4" styleClass="panelColumns">
</h:panelGrid>

and create a css file which contains:

.panelColumns td {
    vertical-align: top; 
} 

just as additional hint .. so you do not have to search to long :)

joerg_wiesmann
  • 161
  • 1
  • 2