【问题标题】:JSF Components alignment inside panelGrouppanelGroup 内的 JSF 组件对齐
【发布时间】:2022-02-10 18:41:22
【问题描述】:

我在 dataTable 中有一个带有 layout="custom"selectOneRadio 元素。下面是xhtml代码-

<p:dataTable var="varlist" value="#{testbean.testlist}">
    <p:column headerText="Choose Option" width="120">
        <p:selectOneRadio id="customRadio" value="#{varlist.varlistValue}"
            layout="custom" required="true">
            <f:selectItem itemValue="10" />
            <f:selectItem itemValue="20" />
        </p:selectOneRadio>

        <h:panelGrid columns="1">
            <h:panelGroup>
                <p:radioButton id="opt1" for="customRadio" itemIndex="0" />
                <h:outputLabel for="opt1" value="OPTION 1" styleClass="radiolabelOption"/>
            </h:panelGroup>

            <h:panelGroup>
                <p:radioButton id="opt2" for="customRadio" itemIndex="1" />
                <h:outputLabel for="opt2" value="OPTION 2" styleClass="radiolabelOption"/>
            </h:panelGroup>
        </h:panelGrid>
    </p:column>
</p:dataTable>

<style type="text/css">
    .radiolabelOption {
      margin-left: 10px;
    }
</style>

这就是它在浏览器中的显示方式-

我们可以看到,outputLabel 相对于 radioButton 显示在底部。但我希望 look center,w.r.t radioButton 如下所示 -

我试过下面的代码行

style="display:block; text-align:center" 或
style="margin: 0 auto;"

但它们都没有产生预期的结果。

那该怎么做呢?

【问题讨论】:

  • 我什至尝试在样式中使用“margin-bottom:..px”来提高 outputLabel 的高度。但它没有用。

标签: css jsf datatable selectoneradio center-align


【解决方案1】:

&lt;h:panelGroup&gt;这些样式

.panelGroup{
  display: flex;
  align-items: center;
}

【讨论】:

  • 另外,我建议多了解flex,它真的很有用!
  • 这很奇怪......这不应该对保证金做任何事情。你是不是打错字了?
  • 看起来'display: flex' 会破坏它。你能从浏览器给我发送“panelGroup”的样式吗?
  • 我为我的项目做了一个全新的构建,它按预期工作。不早点尝试是我的坏事。谢谢你:)
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2013-11-07
  • 2012-09-27
  • 2014-05-03
  • 1970-01-01
  • 2011-05-15
  • 1970-01-01
相关资源
最近更新 更多