且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

JSF panelgrid对齐到顶部

更新时间:2023-12-04 17:35:40

< h:panelGrid> 呈现HTML < table> 元素。表单元格< td> 的垂直对齐默认为 middle 。你想让它顶部。这很容易与CSS。

 < h:panelGrid styleClass =foo> 

  .foo td {
vertical-align:top;
}

如果您要在其中保留一个表格默认表格单元格垂直对齐中间,那么你需要改变CSS如下:

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

,因此只有panelgrid自己的表格单元格顶部对齐。

要了解CSS的所有信息,请检查 http://www.csstutorial.net 。 p>

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.

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.