1

I have a HTML form which I need to format. It is a long form and people have to scroll(Vertically) to access the entire from. Now, I have a lot of white space on the right side of the form fields, I want to divide the form into three sections and display Three sections Horizontally as compared to one long vertical form.

Current Layout:

Field1
Field2
Field3
Field4
Field5
Field6

New Layout:

Field1     Field3     Field5
Field2     Field4     Field6

What is the best way of approaching this?

Thanks in advance

7
  • Using CSS you can wrap the fields and float them. Commented Jul 13, 2012 at 18:21
  • what have you tried? a simple approach may be to use a table but a lot depends on how your page is set up Commented Jul 13, 2012 at 18:21
  • Read about Twitter Bootstrap. It's a "CSS Framework", and it's amazing. But, first of all, go learn CSS. W3Schools is a great place to start. Commented Jul 13, 2012 at 18:22
  • A table would mess up the tabindices here. Commented Jul 13, 2012 at 18:22
  • @AndreCalil I'd recommend MDN instead of w3schools Commented Jul 13, 2012 at 18:23

4 Answers 4

2

In order to acheive the correct tab order (if you don't want to set them manually), you should create one wrapper element for each column and have them float next to eachother.

<div class="col">
<label>Field1 <input type="text"/></label>
<label>Field2 <input type="text"/></label>
</div>
<div class="col">
<label>Field3 <input type="text"/></label>
<label>Field4 <input type="text"/></label>
</div>
<div class="col">
<label>Field5 <input type="text"/></label>
<label>Field6 <input type="text"/></label>
</div>

CSS:

.col{
  width: 30%;
  float: left;
}

...and here's the jsFiddle.

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

Comments

1

You can simply use DIV and CSS

<div class="divContainer">
@foreach(var item in Model.YourCollectionProperty)
{
  <div class="divItem">
       Some content here
  </div>
}
</div>

Have this CSS now

.divContainer
{
   width:100%;
}
.divItem
{
  width:33%; float:left;
}

Comments

0

You can either use a table with 3 columns, or do divs.

Comments

0

I would suggest you use div with css for layouts not table

table is good for tabular data but if need more than that then div is better

http://www.w3schools.com/html/html_layout.asp

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.