DimaSan DimaSan - 5 months ago 11
CSS Question

How to align two commandButtons inside a form

I have two

<p:commandButton>
elements inside
<h:form>
in my .xhtml page.
How to align them center?

enter image description here

Answer

Wrap them in a div or span content and text-align: center that div.

<div class="form-group center">
  <p:commandButton value="C1" action="#{login.login}" />
  <p:commandButton value="C2" action="#{login.login}" />
</div>
<style>
  .center {
    text-align: center;
  }
</style>

There are many many ways to achieve this, and maybe looking into CSS could help understand it a bit more.

Helpful link: https://www.w3.org/Style/Examples/007/center.en.html#block