Place a button right aligned

后端 未结 11 1583
礼貌的吻别
礼貌的吻别 2020-12-22 15:56

I use this code to right align a button.

11条回答
  •  渐次进展
    2020-12-22 16:24

    It is not always so simple and sometimes the alignment must be defined in the container and not in the Button element itself !

    For your case, the solution would be

    I have taken care to specify width=100% to be sure that

    take full width of his container.

    I have also added padding:0 to avoid before and after space as with

    element.

    I can say that if

    is defined in a FSF/Primefaces table's footer, the float:right don't work correctly because the Button height will become higher than the footer height !

    In this Primefaces situation, the only acceptable solution is to use text-align:right in container.

    With this solution, if you have 6 Buttons to align at right, you must only specify this alignment in container :-)

提交回复
热议问题