0

I'm trying to put some input elements (~7) in the same line.

I have the following code:

<form>
  <b> One </b>
 <input type="number" style = "width: 5%; vertical-align:top" class="form-control"  name="quantity" value="1" >
</form>
<form>
  <b> Two </b>
  <input type="number" style = "width: 5%; vertical-align:top" class="form-control"  name="quantity" value="1" >
</form>
<form>
  <b> Three</b>
  <input type="number" style = "width: 5%; vertical-align:top" class="form-control"  name="quantity" value="1" >
</form>

The problem is that every input every input has it own line, and it not in the same line.

Edit: Also, I wish that it will be with space in that way that the inputs elements would comprehend the whole line. Hoe can I do it?

5
  • Get all your input into the same form. Commented Nov 25, 2014 at 15:41
  • @Veve: It still makes line for each input Commented Nov 25, 2014 at 15:45
  • Set every form tag style="display: inline;" Commented Nov 25, 2014 at 15:45
  • the inputs elements would comprehend the whole line Not sure what you mean by this Commented Nov 25, 2014 at 15:46
  • @MLeFevre: Sorry. I mean that between each input element would be equal spaces, so the input elements would be on the entire row Commented Nov 25, 2014 at 15:48

3 Answers 3

1

Change the display, remove the inline styles. Example: http://jsfiddle.net/ys1Lgj7e/

form {
    display:inline-block;
}
Sign up to request clarification or add additional context in comments.

Comments

0

Your input elements should all share the same form, and your styling can be modified & put into CSS, which will simplify your code significantly.

Here's a working example:

http://jsfiddle.net/u4utpu6c/

HTML

<form>
<input type="number" />
<input type="number" />
<input type="number" />
</form>

CSS

input {
display: inline;
width: 5%; 
vertical-align:top;
}

2 Comments

Thanks. How can I do equal spaces between each input? so the last input element would be in the end of the line?
Fiddle has been updated. You'll want to put the inputs in divs, so that the width of the page division is different than the width of the input field. Also, I changed the width of the input field to be in "em" units, which is much better for inputs than percentages.
0

Set every form tag to 'display: inline;'

In that html file:

<style>
form {
    display: inline;
}
</style>

OR in your css file:

form {
    display: inline;
}

OR each tag :

<form style="display: inline;">

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.