0

I have an advanced search form (click "Advanced search") here in Dupal 7 - http://www.ibuild.ph/mtf-rdp-minimal/search/node and contact form here - http://www.ibuild.ph/mtf-rdp-minimal/contact. The search fields are inline, while the contact fields are positioned below the labels.

Is there a way to inline position the fields with the text labels and make the fields aligned vertically with each other without separating the text labels and form fields in two divs?

3 Answers 3

2

Using table

You can change width of label by changing width: 100px;

<table style="width: 100%;">
<colgroup>
    <col style="width: 100px;">
    <col>
<colgroup>
<tr>
    <td>Name</td>
    <td><input type="text" /></td>
</tr>
  
<tr>
    <td>Address</td>
    <td><input type="text" /></td>
</tr>
  
</table>

Using min-width:

<div>
  <label style="display: inline-block; min-width: 100px;">Name: </label><input type="text" />  
</div>
    
<div>
  <label style="display: inline-block; min-width: 100px;">Address: </label><input type="text" />  
</div>

Sign up to request clarification or add additional context in comments.

2 Comments

Since this is the accepted answer, you should update your html to have valid closing tags. I wouldn't want someone to paste your answer in their editor and end up more confused than they started.
Thanks for your response, I have edited closing tags.
1

You could do either of these things:

Make a <table> with two columns instead of your <fieldset>.

Put the <label> elements in the first column and <input/> elements in the second column. The table will automatically align the column widths to the largest element in that column.

OR

You could add this to your css:

fieldset.search-advanced label{
    min-width:200px;
}

Comments

0

Thanks, Thi Tran and FactoryAidan. Will try customizing Drupal's webform tpl instead. But your answers will definitely come in handy in customizing the template.

Here is the link to the resource I have found - http://cgit.drupalcode.org/webform/tree/THEMING.txt?id=HEAD

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.