1

例如,现在我正在尝试向包含 X 按钮的页面添加一个 panelGrid。每个按钮都有不同的长度,具体取决于文本与其关联的长度。我希望能够在 panelGrid 级别指定,以确保每个组件都拉伸以满足 panelGrid 本身的宽度 - 而不必手动设置 X 个按钮的宽度。

它必须与 columnClasses 相关并通过 CSS 设置宽度,但我所做的尝试没有奏效。例如,我将 panelGrid 上的 styeClass 设置为宽度为 100 像素的类。然后我尝试将 ColumnClass 也设置为该 CSS 类 - 仍然没有骰子。

想法?

4

1 回答 1

2

为此panelGrid...

  <h:panelGrid styleClass="panelGridClass" columns="2">
    <h:commandButton value="b1" />
    <h:commandButton value="button 2" />
    <h:commandButton value="button 3 is really long" />
    <h:commandButton value="b4" />
  </h:panelGrid>

您可以使用此 CSS 将按钮设置为等宽:

TABLE.panelGridClass {
    width: 300px;
}
TABLE.panelGridClass TR TD {
  width: 50%;
}
TABLE.panelGridClass TR TD INPUT {
    width: 95%;
}

这将表格设置为 300 像素宽,单元格设置为表格宽度的一半,按钮占据大部分单元格宽度。如果按钮的自然长度超过 150 像素,则列的宽度可能不相等,但您可以使用溢出规则或其他方式克服这一问题。

于 2009-10-01T09:41:58.870 回答