问题与水平中心对齐的内容

时间:2013-05-08 03:41:59

标签: css jsf-2 primefaces

在我的JSF-PrimeFaces webapp中,我需要将其内容水平对齐到中心。我怎么能这样做?

以下是代码:

    <p:panel id="businesses_panel" header="#{business.businessName}" styleClass="mini-panel panel-grid tr panel-grid td panel-hover panel-header-title-small">
<div align="center">
    <p:panelGrid columns="1">
        <div class="component-spacing-top"/>
        <h:graphicImage alt="#{business.businessName}" value="#{business.logoFullPath}" class="small-panel-image" />
        <div class="component-spacing-top"/>
    </p:panelGrid>
</div>
</p:panel>

2 个答案:

答案 0 :(得分:1)

align="center"已弃用。您应该使用css,尝试:

            <style type="text/css">
                .test table{
                    margin-left: auto !important;
                    margin-right: auto !important;
                }
            </style>
            <p:panel styleClass="test">
                   ...
            </p:panel>

另见:

答案 1 :(得分:0)

你可以试试这个:

<style type="text/css">
    #businesses_panel .ui-panel-content {
        margin-left:  auto !important;
        margin-right: auto !important;
    }
</style>