0

I have a simple form with two columns and a field that consists of three inputs (see attached image) enter image description here The two columns are floated right. I need to add a dash between the fields in "Adószám". I tried it with :before pseudo class but it didn't display anything. If I just add it to the HTML markup, the fields are wrapped to the next line.

Here is my HTML:

<div id="column1">
                <label for="name">Név:<br /><input type="text" id="name" name="name" /></label>
                <label for="pass">Jelszó:<br /><input type="text" id="pass" name="pass" /></label>
                <input type="checkbox" id="accept" name="accept" value="1" /> Elfogadom a feltételeket
            </div>
            <div id="column2">
                <label for="email">E-mail cím:<br /><input type="text" id="email" name="email" /></label>
                <label for="taxno1">Adószám:<br />
                <input type="text" id="taxno1" name="taxno1" />
                <input type="text" id="taxno2" name="taxno2" />
                <input type="text" id="taxno3" name="taxno3" />
            </label>

And my CSS:

    #column1 {
    margin-right: 50px;
    display: inline-block;
    width: 270px;
    float: left;
}

#column2 {    
    display: inline-block;
    width: 270px;
    float: left;
}

label {
    font-weight: bold;
    /*display: inline-block;*/
}

input {
    width: 255px;
    /*display: inline-block;*/
    height: 28px;
    border: 1px solid #c3c6d1;
    background-color: #eaecf2;
    margin: 5px 0 5px 0;
    font-size: 15px;
    padding: 5px;
}

#taxno1 {
    width: 82px;
}

#taxno2, #taxno3 {
    width: 46px;
    margin-left: 23px;
}
Moha
  • 857
  • 2
  • 12
  • 25

2 Answers2

0

please review this code

<div id="column1">
                <label for="name">Név:<br /><input type="text" id="name" name="name" /></label>
                <label for="pass">Jelszó:<br /><input type="text" id="pass" name="pass" /></label>
                <input type="checkbox" id="accept" name="accept" value="1" /> Elfogadom a feltételeket
            </div>
            <div id="column2">
                <label for="email">E-mail cím:<br /><input type="text" id="email" name="email" /></label>
                <label for="taxno1">Adószám:<br />
                <input type="text" id="taxno1" name="taxno1" /> -
                <input type="text" id="taxno2" name="taxno2" /> -
                <input type="text" id="taxno3" name="taxno3" />
            </label>

#taxno2, #taxno3 {
    width: 46px;
    margin-left: 10px;
}

Demo here http://jsfiddle.net/z9b5S/

Karthick Kumar
  • 2,349
  • 1
  • 17
  • 30
  • Yes, I tried this but I need to maintain the total width of the 3 input fields (to be aligned with the wider input above it) on every system. And the width of the dash can be different depending on operating system and browser – Moha Mar 12 '14 at 08:10
0

you have to wrap the input inside a span and then giving a class to span element it will work.

 <div id="column2">
                <label for="email">E-mail cím:<br /><input type="text" id="email" name="email" /></label>
                <label for="taxno1">Adószám:<br />

                  <span class="add"><input type="text" id="taxno1" name="taxno1" /></span>
                 <span class="add"><input type="text" id="taxno2" name="taxno2" /></span>
                 <span class="add"><input type="text" id="taxno3" name="taxno3" /></span>
            </label>
  </div>

And add this class in your CSS file.

.add:after
{
    content: "/"; 
}
.add:last-child:after{
   content: " "; 
}

A working Demo link is here.. http://jsbin.com/qeduhogi/3/

Kheema Pandey
  • 9,977
  • 4
  • 25
  • 26