【问题标题】:How to align <h:panelGrid> itself NOT items in a center?如何对齐 <h:panelGrid> 本身而不是中心的项目?
【发布时间】:2012-12-16 15:43:28
【问题描述】:

当我使用这个 sn-p 代码时

<h:panelGrid id="myGrid" columns="1"
rendered="#{myBean.showResults}" width="50%"
border="1" style="text-align: center;">  

panelGrid的项目将集中
但是
我想将 h:panelGrid 本身集中在我的 XHTML 页面的中心
喜欢这个 HTML 代码

<table id="myGrid" border="1" align="center">

【问题讨论】:

标签: html css jsf


【解决方案1】:

假设它有一个已知的宽度,给它一个左右边距auto。这样,它将相对于父块元素居中。

<h:panelGrid ... style="margin: 0 auto;">

另见:

【讨论】:

    【解决方案2】:

    将它包裹在一个具有页面大小的面板网格中,并将父网格的样式设置为文本居中对齐。然后您的子网格将在页面上居中(从您的子面板网格中删除 text-align: center 样式

    【讨论】:

      猜你喜欢
      • 2011-04-12
      • 1970-01-01
      • 2014-04-28
      • 2012-01-08
      • 2022-01-16
      • 1970-01-01
      • 2017-02-16
      • 2015-11-09
      • 1970-01-01
      相关资源
      最近更新 更多