How to align items in a to the right

前端 未结 3 1390
萌比男神i
萌比男神i 2020-12-01 17:03

How would I align everything in my below to the far right?

相关标签:
3条回答
  • 2020-12-01 17:26

    The <h:panelGrid> renders a HTML table. You basically want to apply text-align: right; on every <td> element it renders. With the current code, easiest would be to apply the following:

    #authenticate table td {
        text-align: right;
    }
    

    You can of course also be more specific, e.g. giving the <h:panelGrid> its own styleClass and defining a rule in CSS (which would be applied directly on the rendered HTML <table> element).

    <h:panelGrid styleClass="className">
    

    with

    .className td {
        text-align: right;
    }
    

    You can also give each <td> element its own class by columnClasses attribute which accepts a commaseparated string of CSS classnames which are to be applied repeatedly on the <td> elements. If you want to apply the same class on every <td> element, just specify it once:

    <h:panelGrid columnClasses="className">
    

    with

    .className {
        text-align: right;
    }
    

    As an extra hint: rightclick the webpage in webbrowser and choose View Source, then you'll understand better what JSF is all exactly generating.

    0 讨论(0)
  • 2020-12-01 17:28

    A little late, but might help someone, as it was what I needed...

    If the alignment is not limited to this specific table, but rather the default format for all table cells, then just add this to your CSS file:

    td {
        text-align: right;
    }
    

    Then, all <td> elements, including those generated by JSF, will be formatted that way.

    0 讨论(0)
  • 2020-12-01 17:40

    actually in same form i used <p:panel> and got good result. looks like ;

    <p:panel  styleClass="ui-panel-titlebar ui-widget-header ui-helper-clearfix ui-corner-all">
        <p:commandButton value="Add New Tab"
                actionListener="#{xxx.createNewTab}" process="@this"
                update="tabView" style="float:right !important;margin:0px 0px 3px 0px;" />
                </p:panel>
    
    0 讨论(0)
提交回复
热议问题