Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JSF panelgrid alignment to top

I see there are some answers posted for this. tried almost all of them with several permutation-combination.. but nothing seems to be working.

components inside panelgris are always middle aligned, instead of top.

tried whatever they said in the below post. How to control alignment of DataTable inside of a PanelGrid?

Please let me know if there is a remedy.

like image 893
user644745 Avatar asked Jul 26 '11 17:07

user644745


2 Answers

Use the panelGrid's columnClasses attribute to identify a CSS class that includes the vertical-align: top; style:

<h:panelGrid columns="2" columnClasses="topAligned">
...
</h:panelGrid>

and the CSS file:

.topAligned {
    vertical-align: top;
}

The contents of the first column in the panelGrid will then be top-aligned within their cells.

like image 196
Kevin Rahe Avatar answered Oct 01 '22 12:10

Kevin Rahe


The <h:panelGrid> renders a HTML <table> element. The vertical alignment of a table cell <td> defaults indeed to middle. You want to make it to be top instead. This is easy with CSS.

<h:panelGrid styleClass="foo">

with

.foo td {
    vertical-align: top;
}

If you have a table inside the panelgrid for which you'd like to keep the default table cell vertical alignment of middle, then you need to alter the CSS as follows:

.foo>tbody>tr>td {
    vertical-align: top;
}

so that only the panelgrid's own table cells are top aligned.

To learn all about CSS, check http://www.csstutorial.net.

like image 32
BalusC Avatar answered Oct 01 '22 14:10

BalusC