Aligning content inside panelGrid columns

Rajat Gupta picture Rajat Gupta · Jun 13, 2011 · Viewed 51.5k times · Source

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.

Answer

Dejell picture Dejell · Jun 13, 2011

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

<h:panelGrid columnClasses="className">

.className {
    vertical-align: top;
}