【发布时间】:2013-11-26 01:37:49
【问题描述】:
我正在尝试将 styleClass 应用于 h:panelGrid 而不将其应用于其子代:
<h:panelGrid id="mainPanelGrid" columns="2" width="100%" styleClass="topAligned" >
<p:fieldset id="fs1" legend="fs1" style="width: max-content">
<h:panelGrid columns="3">
<p:outputLabel for="id1" value="#{messages.label_application}" />
<p:selectOneMenu id="id1" required="true" value="som">
<f:selectItem itemLabel="#{messages.label_select}" noSelectionOption="true" />
<f:selectItems value="#{bean.availableItems}" />
</p:selectOneMenu>
<p:message for="id1" />
</h:panelGrid>
</p:fieldset>
<p:fieldset id="fs2" legend="fs2" style="width: max-content">
<h:panelGrid columns="3">
<!--more fields-->
</h:panelGrid>
</p:fieldset>
</h:panelGrid>
我的 topAligned css:
.topAligned td{
vertical-align: top !important;
}
问题是我需要将两个字段集顶部对齐,这与我申请的styleClass 效果很好,但它也将这个styleClass 应用于所有孩子。因此,两个字段集的所有字段(outputLabel、selectOneMenu 等...)也都顶部对齐...
我尝试了所有不同的方法来指定 this question 的顶部对齐方式,但没有成功...我还尝试查看 html 源代码,但它与所有 jsf 和 primefaces 的东西有点混淆...
如果你知道一个可行的技巧......
【问题讨论】:
-
您可以随时删除
!important并覆盖子元素,或者巧妙地使用css:not选择器。这一切都取决于您生成的 DOM。尝试在没有 PF 乱码的情况下上传您的输出。