2016-07-03 4 views
1

私は次のような連絡先フォームを作成しようとしています。commandButtonの幅を設定する

+----------------+-------------------+ 
| Name:   |     | 
+----------------+-------------------+ 
| Email Address: |     | 
+----------------+-------------------+ 
| Website:  |     | 
+----------------+-------------------+ 
| Comment:  |     | 
+----------------+-------------------+ 
|    Send     | 
+------------------------------------+ 

これまでのところ、ラベルとテキストをグリッドに配置しました。 私のボタンはこのように見えます。

... 
+----------------+-------------------+ 
| Comment:  |     | 
+----------------+-------------------+ 
| Send | 
+------+ 

しかし、最初のもののように見え、他のコンポーネントの幅と揃えたいと思っています。

<p:panelGrid columns="2"> 
    <h:outputLabel value="Name:" /> 
    <p:inputText value="#{contactFormController.name}" required="true" /> 

    <h:outputLabel value="Email Address:" /> 
    <p:inputText value="#{contactFormController.email}" required="true" /> 

    <h:outputLabel value="Website:" /> 
    <p:inputText value="#{contactFormController.website}" required="false" /> 

    <h:outputText value="Comment:" /> 
    <p:inputText value="#{contactFormController.comment}" required="true" /> 

    <p:commandButton value="Send" actionListener="#{contactFormController.sentMail}"/> 
</p:panelGrid> 
+0

レンダリングされたCCSとHTMLを投稿して、何を提案するか確認してください。 – LGSon

+0

これは私の.xhtmlコードブロックです。私はプライムフェイスの元のCSSを上書きしませんでした。 –

答えて

0

のようなものを試してみてください:

<!-- contact-form.html --> 

<div class="contact-form"> 
    <div class="cf-input"> 
    <label for="cf-name">Name:</label> 
    <input id="cf-name" type="text"> 
    </div> 
    <div class="cf-input"> 
    <label for="cf-email">Email Address:</label> 
    <input id="cf-email" type="text"> 
    </div> 
    <div class="cf-input"> 
    <label for="cf-website">Website:</label> 
    <input id="cf-website" type="text"> 
    </div> 
    <div class="cf-input"> 
    <label for="cf-comment">Comment:</label> 
    <input id="cf-comment" type="text"> 
    </div> 
    <button>Send</button> 
</div> 

その後、あなたはこのようなあなたのCSSをレイアウトすることができます

<p:panelGrid> 
    <p:row> 
     <p:column> 
      <h:outputLabel value="Name:" /> 
     </p:column> 
     <p:column> 
      <p:inputText value="#{contactFormController.name}" required="true" /> 
     </p:column> 
    </p:row> 

//other columns here 

    <p:row colspan="2" > 
     <p:commandButton value="Send" actionListener="#{contactFormController.sentMail}"/> 
    <p:row> 
</p:panelGrid> 
0

これはflexメソッドを使用したオプションです。

まず、このようにHTMLをレイアウト:ここでフィドルをチェック

/** contact-form.css **/ 

.contact-form { 
    display: flex; 
    flex-flow: column nowrap; 
    width: 300px; /* Set size of contact form */ 
} 

.contact-form > .cf-input { 
    display: flex; 
    margin: 5px 0; /* Optional: Adds space between each input */ 
} 

.contact-form > .cf-input > label { 
    min-width: 125px; /* Width of labels */ 
} 

.contact-form > .cf-input > input { 
    flex: 1 0 auto; /* Expands input fields to fill remaining space */ 
} 

.contact-form > button { 
    width: 100px; /* Set to whatever. This is the width of the button */ 
    align-self: center; 
} 

https://jsfiddle.net/chengsieuly/mfxbu7fj/7/

関連する問題