HTML/CSS aligning two inputs and text underneath - html

I am trying to place two input forms next to eachother and position some text underneath them. Somehow it never ends up aligned correctly. This picture shows what I am trying to do:
HTML:
<form action="#" class="cleanForm" method="POST">
<fieldset>
<input type="text" name="firstname" placeholder="first name" required>
<em>Please enter your first name</em>
<input type="text" name="lastname" placeholder="last name" required>
<em>Enter your last name</em>
<input type="email" name="email" placeholder="e-mail" required>
<em>Enter your e-mail address</em>
<input type="email" name="email2" placeholder="re-enter e-mail" required>
<em>Re-enter your e-mail address</em>
<input type="password" name="password" placeholder="password" required>
<em>Enter a password between 8 and 20 digits</em>
<input type="password" name="password2" placeholder="re-enter password" required />
<em>Re-enter the password</em>
<p>
<input type="radio" name="gender" value="Female" checked>
<label for="female">Female</label>
<input type="radio" name="gender" value="Male">
<label for="male">Male</label>
</p>
<p>
<input type="checkbox" id="agree-TOS">
<label for="agree-TOS">I have read and agree to the Terms of Service.</label>
</p>
<input type="submit" value="Create account">
</fieldset>
</form>
CSS:
form.cleanForm {
width:700px;
margin:0 auto;
}
form.cleanForm p {
margin-bottom:15px;
}
input[type="email"], input[type="password"], input[type="text"] {
font-family: Arial, Sans-Serif;
font-size: 18px;
color: #adadad;
padding: 10px;
outline:none;
float:left;
border: solid 1px #adadad;
width: 230px;
transition: all 2s ease-in-out;
-webkit-transition: all 2s ease-in-out;
-moz-transition: all 2s ease-in-out;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
border-radius: 8px;
-moz-box-shadow:inset 0 0 5px 5px #E6E6E6;
-webkit-box-shadow:inset 0 0 5px 5px #E6E6E6;
box-shadow:inset 0 0 5px 5px #E6E6E6;
clear: right;
}
input[type="email"]:focus, input[type="email"]:hover, input[type="password"]:focus,
input[type="password"]:hover, input[type="text"]:focus, input[type="text"]:hover {
border:1px solid #FF003F;
}
form.cleanForm em {
font-size:12px;
}

You're applying float:left to the <input>s, but not to the <em>s. That's why all the fields are pushed to the left, while the labels remain in the ordinary page flow.
One possible solution is wrapping both of them in a <div> and applying the float to that:
HTML:
<div class="field">
<input type="text" name="firstname" placeholder="first name" required />
<em>Please enter your first name</em>
</di>
CSS:
div.field {
float: left;
}
Also, it would be more sematically correct to use a <label> instead of an <em>.

I think your markup needs a redo. Use <label>s to describe form element labels, not <em>s. There's no semantic value in the emphasis. Also, you can use the labels themselves to align the form easily. Here's my code (Live Example Here):
HTML
<form action="#" class="cleanForm" method="POST">
<fieldset>
<label><input type="text" name="firstname" placeholder="first name" required>
Please enter your first name</label>
<label><input type="text" name="lastname" placeholder="last name" required>
Enter your last name</label>
<label><input type="email" name="email" placeholder="e-mail" required>
Enter your e-mail address</label>
<label><input type="email" name="email2" placeholder="re-enter e-mail" required>
Re-enter your e-mail address</label>
<label><input type="password" name="password" placeholder="password" required>
Enter a password between 8 and 20 digits</label>
<label><input type="password" name="password2" placeholder="re-enter password" required>
Re-enter the password</label>
<div id="gender">
<label><input type="radio" name="gender" value="Female" checked>
Female</label>
<label><input type="radio" name="gender" value="Male">
Male</label>
</div>
<label class="tos"><input type="checkbox" id="agree-TOS">
I have read and agree to the Terms of Service.</label>
</fieldset>
<button type="submit">Create account</button>
</form>
CSS
.cleanForm {
width: 550px;
}
fieldset > label > input {
display: block;
}
input[type="checkbox"] {
display: inline;
}
label {
margin: 10px;
padding: 5px;
}
fieldset > label {
float: left;
width: 200px;
}
label:nth-child(2n+1) {
clear: both;
}
#gender, .tos, button {
clear: both;
}
.tos {
width: 400px;
}
input[type="text"], input[type="email"], input[type="password"] {
-webkit-border-radius: 5px;
-moz-border-radius: 5px;
border-radius: 5px;
-webkit-box-shadow: inset 2px 2px 3px rgba(0, 0, 0, 0.2);
-moz-box-shadow: inset 2px 2px 3px rgba(0, 0, 0, 0.2);
box-shadow: inset 2px 2px 3px rgba(0, 0, 0, 0.2);
padding: 5px;
}

You may try this:
HTML
<form action="#" class="cleanForm" method="POST">
<fieldset>
<div class="column">
<input type="text" name="firstname" placeholder="first name" required />
<em>Please enter your first name</em>
</div>
<div class="column last">
<input type="text" name="lastname" placeholder="last name" required />
<em>Enter your last name</em>
</div>
<div class="column">
<input type="email" name="email" placeholder="e-mail" required />
<em>Enter your e-mail address</em>
</div>
<div class="column last">
<input type="email" name="email2" placeholder="re-enter e-mail" required />
<em>Re-enter your e-mail address</em>
</div>
<div class="column">
<input type="password" name="password" placeholder="password" required />
<em>Enter a password between 8 and 20 digits</em>
</div>
<div class="column last">
<input type="password" name="password2" placeholder="re-enter password" required /><br />
<em>Re-enter the password</em>
</div>
<p style="clear:both;">
<input type="radio" name="gender" value="Female" checked />
<label for="female">Female</label>
<input type="radio" name="gender" value="Male" />
<label for="male">Male</label>
</p>
<p>
<input type="checkbox" id="agree-TOS" />
<label for="agree-TOS">I have read and agree to the Terms of Service.</label>
</p>
<input type="submit" value="Create account" />
</fieldset>
</form>
CSS
form.cleanForm {
width:700px;
margin:0 auto;
}
form.cleanForm p {
margin-bottom:15px;
}
input[type="email"], input[type="password"], input[type="text"] {
font-family: Arial, Sans-Serif;
font-size: 18px;
color: #adadad;
padding: 10px;
outline:none;
float:left;
border: solid 1px #adadad;
width: 230px;
transition: all 2s ease-in-out;
-webkit-transition: all 2s ease-in-out;
-moz-transition: all 2s ease-in-out;
-moz-border-radius: 8px;
-webkit-border-radius: 8px;
border-radius: 8px;
-moz-box-shadow:inset 0 0 5px 5px #E6E6E6;
-webkit-box-shadow:inset 0 0 5px 5px #E6E6E6;
box-shadow:inset 0 0 5px 5px #E6E6E6;
clear: right;
}
input[type="email"]:focus, input[type="email"]:hover, input[type="password"]:focus, input[type="password"]:hover, input[type="text"]:focus, input[type="text"]:hover {
border:1px solid #FF003F;
}
form.cleanForm em {
font-size:12px;
}
.column{
width:250px;
float:left;
margin-right:20px;
padding: 10px;
}
.last{
margin:0;
padding: 10px;
}
Output

#PPvG's answer is very close, but not perfect:
In almost all cases, every <input> tag should have a matching <label> tag, and where you have used <em> is a perfect place for a label.
In this case, inline-block is more appropriate than float
Here's how I would do it:
HTML:
<div class="field">
<input type="text" name="firstname" id="firstname_field" placeholder="first name" required />
<label for="firstname_field">Please enter your first name</label>
</div>
CSS:
div.field {
display: inline-block;
width: 200px;
}
div.field label
{
display: block;
}

Related

Input animation with CSS and HTML

I`m trying to make an animation in CSS, in which I have an INPUT (text) and a Label, This label has a text. When the user clicks the Input, I want the text from the label to go up, above the input.
.tpinput{
width: 50%;
display: block;
margin-top: 25px;
margin-left: -20px;
padding: 7px;
font-size: 15px;
color: black;
outline: none;
background: transparent;
border: none;
border-bottom: 1px solid #0043FF;
}
.tplabel{
position: relative;
margin-left: -25px;
top: -75px;
transition: 0.4s ease;
color: #0043FF;
}
.cadastro input:focus + .tplabel {
top: -70px;
font-size: 18pt;
left: -10px;
}
<div class="alinhamento">
<h1 id="cadtitulo">Cadastro</br></h1>
<form action="includes/signup.inc.php" method="POST">
<div class="cadastro">
<input type="text" id="nomecomp" name="nomecomp" class="tpinput" required/>
</br>
<label for="nomecomp" class="tplabel"><span class="content-name">Nome Completo</span></label>
<input type="text" class="tpinput1" id="signup-nome" name="nome" required/>
<label for="signup-nome" class="tplabel1"><span class="content-name">Username</span></label>
</br>
<input type="email" id="signup-email" name="email" class="tpinput2" required/>
<label for="signup-email" class="tplabel2"><span class="content-name">Email</span></label>
</br>
<input type="password" id="signup-password" name="snh" class="tpinput3"required/>
<label for="signup-password" class="tplabel3"><span class="content-name">Senha</span></label>
</br>
<input type="password" id="signup-password1" name="snh-repetir" class="tpinput4"required/>
<label for="signup-password1" class="tplabel4"><span class="content-name">Repetir senha</span></label>
</br>
<input type="tel" id="telefone" name="telefone" class="tpinput5" maxlength="13" required/>
<label for="telefone" class="tplabel5"><span class="content-name">Telefone</span></label>
</br>
<input type="text" id="chave" name="chave" class="tpinput6" required/>
<label for="chave" class="tplabel6"><span class="content-name">Key</span></label>
</br>
<button type="submit" class="btn-register" name="registrar">Registrar</button>
</div>
</form>
</div>
I want it to work for all the other labels too.

Form CSS wont change

I am trying to add an image to my email input field and change some coloring. Any changes to my CSS won't make a change at all in my code. My CSS page is linked correctly as well. The CSS I added below was added, after adding this CSS code, any other changes won't be made. Any help is appreciated.
HTML:
<article>
<h3>Information</h3>
<p>
<label for="firstName">First Name:</label>
<input type="text" name="firstName" id="firstName">
</p>
<p>
<label for="lastName">Last Name:</label>
<input type="text" name="lastName" id="lastName">
</p>
<p>
<label for="userEmail">Email:</label>
<input type="email" name="userEmail" id="userEmail">
</p>
<p>
<label for="userPassword">Password:</label>
<input type="password" name="userPassword" id="userPassword">
</p>
<h3>Questionair</h3>
<p>
<label for="textInfo">Why do you want to adopt?:</label>
<textarea cols="30" rows="5" id="textInfo"></textarea>
<p> </p>
<fieldset>
<legend>What type of animal are you looking to adopt?</legend>
<label><input type="radio" name="dog" value="dog" id="dog">Dog</label>
<br>
<label><input type="radio" name="cat" value="cat" id="cat">Cat</label>
<br>
<label><input type="radio" name="bird" value="bird"
id="bird">Bird</label>
<br>
</fieldset>
<p> </p>
<fieldset>
<legend>Choose a gender?</legend>
<label><input type="checkbox" name="male" value="male"
id="male">Male</label>
<br>
<label><input type="checkbox" name="female" value="female"
id="female">Female</label>
<br>
<label><input type="checkbox" name="either" value="either"
id="either">Dosent Matter</label>
<br>
</fieldset>
<p> </p>
<p>
<label for="otherPets"> Do you own other pets?</label>
<select name="otherPets" id="otherPets">
<option value="hasOtherPets">Yes</option>
<option value="noOtherPets">No</option>
</select>
</p>
<p>
<input type="submit" id="submitForm" value="Submit">
</p>
</article>
</form>
CSS:
the input block was added and changes were made accordingly, the code under that (starting at input [type=submit] is where CSS stopped changing after the code was created.
input {
font-size: 120%;
color: #5a5854;
background-color: #f2f2f2;
border: 1px solid #bdbdbd;
border-radius: 5px;
padding: 5px 5px 5px 30px;
background-repeat: no-repeat;
background-position: 8px 9px;
display: block;
margin-bottom: 10px;
}
input:focus {
background-color: #ffffff;
border: 1px solid #b1e1e4;
}
input [type= submit] {
background-color: #E88940;
color: #FFEBCD;
}
input #userEmail {
background-image: url("../Images/mail.png");
}
It's the CSS that's wrong. input #userEmail is not accepted. That difference makes a huge effect on the page. Even though it's a tiny mistake, to correct it input#userEmail does what you need. What went wrong was just a simple typographic error in CSS.
EDIT: When I tried your HTML in JSFiddle, I see a error that says Missing </p> at the end. Turns out you started a paragraph and never ended it.
This is the correct HTML and CSS:
input {
font-size: 120%;
color: #5a5854;
background-color: #f2f2f2;
border: 1px solid #bdbdbd;
border-radius: 5px;
padding: 5px 5px 5px 30px;
background-repeat: no-repeat;
background-position: 8px 9px;
display: block;
margin-bottom: 10px;
}
input:focus {
background-color: #ffffff;
border: 1px solid #b1e1e4;
}
input[type=submit] {
background-color: #E88940;
color: #FFEBCD;
}
input#userEmail {
background-image: url("../Images/mail.png");
}
<form>
<article>
<h3>Information</h3>
<p>
<label for="firstName">First Name:</label>
<input type="text" name="firstName" id="firstName">
</p>
<p>
<label for="lastName">Last Name:</label>
<input type="text" name="lastName" id="lastName">
</p>
<p>
<label for="userEmail">Email:</label>
<input type="email" name="userEmail" id="userEmail">
</p>
<p>
<label for="userPassword">Password:</label>
<input type="password" name="userPassword" id="userPassword">
</p>
<h3>Questionair</h3>
<p>
<label for="textInfo">Why do you want to adopt?:</label>
<textarea cols="30" rows="5" id="textInfo"></textarea>
</p>
<p> </p>
<fieldset>
<legend>What type of animal are you looking to adopt?</legend>
<label><input type="radio" name="dog" value="dog" id="dog">Dog</label>
<br>
<label><input type="radio" name="cat" value="cat" id="cat">Cat</label>
<br>
<label><input type="radio" name="bird" value="bird"
id="bird">Bird</label>
<br>
</fieldset>
<p> </p>
<fieldset>
<legend>Choose a gender?</legend>
<label><input type="checkbox" name="male" value="male"
id="male">Male</label>
<br>
<label><input type="checkbox" name="female" value="female"
id="female">Female</label>
<br>
<label><input type="checkbox" name="either" value="either"
id="either">Dosent Matter</label>
<br>
</fieldset>
<p> </p>
<p>
<label for="otherPets"> Do you own other pets?</label>
<select name="otherPets" id="otherPets">
<option value="hasOtherPets">Yes</option>
<option value="noOtherPets">No</option>
</select>
</p>
<p>
<input type="submit" id="submitForm" value="Submit">
</p>
</article>
</form>
This should do the trick.
You just need to remove the whitespace between your property selector and or ID..
input {
font-size: 120%;
color: #5a5854;
background-color: #f2f2f2;
border: 1px solid #bdbdbd;
border-radius: 5px;
padding: 5px 5px 5px 30px;
background-repeat: no-repeat;
background-position: 8px 9px;
display: block;
margin-bottom: 10px;
}
input:focus {
background-color: #ffffff;
border: 1px solid #b1e1e4;
}
input[type=submit] {
background-color: #E88940;
color: #FFEBCD;
}
input#userEmail {
background-image: url("../Images/mail.png");
}

Blocks besides each others

I have a given HTML which I can't touch:
<fieldset>
<label for="username" class="text">
Dein Benutzername<span class="req">*</span>
</label>
<div class="div_text">
<input name="username" type="text" id="username" value="" class="textbox" required="">
</div>
<label for="first_name" class="text">
Vorname<span class="req">*</span>
</label>
<div class="div_text">
<input name="first_name" type="text" id="first_name" value="" class="textbox" required="">
</div>
<label ....
and I need to output that one with 2 same-width columns where the label is above the corresponding div-block and the next input-div-block and their corresponding label is besides it.
I added an image to show exactly what I want it to be. I run into problems because the label-tag sits within the same hierarchy-level as the div-block and I therefore can't use inline-block nor - due to my lack of knwoledge - flexbox as it's a mix between column and row in flex-direction
Could somebody please guide me on that one?
You can still use flexbox and put the elements into a new order. It is not a elegant way but the only solution i can
think of if you cant touch the HTML
.text,
.div_text {
width: 50%;
display: block;
}
fieldset {
display: flex;
flex-wrap: wrap;
}
label {
display: block;
}
label[for=username] {
order: 1;;
}
label[for=first_name] {
order: 2;
}
fieldset div:nth-of-type(1){
order: 3;
}
fieldset div:nth-of-type(2){
order: 4;
}
label[for=sur_name] {
order: 5;
}
label[for=example] {
order: 6;
}
fieldset div:nth-of-type(3){
order: 7;
}
fieldset div:nth-of-type(4){
order: 8;
}
<fieldset>
<label for="username" class="text">Dein Benutzername<span class="req">*</span></label>
<div class="div_text">
<input name="username" type="text" id="username" value="" class="textbox" required="">
</div>
<label for="first_name" class="text">Vorname<span class="req">*</span></label>
<div class="div_text">
<input name="first_name" type="text" id="first_name" value="" class="textbox" required="">
</div>
<label for="sur_name" class="text">Nachname<span class="req">*</span></label>
<div class="div_text">
<input name="sur_name" type="text" id="sur_name" value="" class="textbox" required="">
</div>
<label for="example" class="text">Weiters Beispiel<span class="req">*</span></label>
<div class="div_text">
<input name="example" type="text" id="example" value="" class="textbox" required="">
</div>
</fieldset>
Hoping you are not using any css framework, please have a look at the below-working snippet with custom markup and css, hope it helps :)
body {
font-size: 14px;
font-family: sans-serif;
}
fieldset {
clear: both;
max-width: 500px;
border: 1px dashed deeppink;
}
legend {
color: #fff;
font-size: 14px;
padding: 5px 10px;
background: deeppink;
margin: 0 0 10px 15px;
}
.form-group {
width: 45%;
float: left;
padding: 0 2.5%;
}
label {
display: block;
margin-bottom: 5px;
}
input[type="text"] {
width: 100%;
font-size: 14px;
padding: 5px 3px;
margin-bottom: 10px;
border: 1px solid #000;
box-sizing: border-box;
}
<fieldset>
<legend>Fieldset Container</legend>
<div class="form-group">
<label for="labelX">Label x</label>
<input id="labelX" type="text" placeholder="Label X" />
</div>
<div class="form-group">
<label for="labelY">Label y</label>
<input id="labelY" type="text" placeholder="Label Y" />
</div>
<div class="form-group">
<label for="labelZ">Label z</label>
<input id="labelZ" type="text" placeholder="Label Z" />
</div>
<div class="form-group">
<label for="labelXX">Label xx</label>
<input id="labelXX" type="text" placeholder="Label XX" />
</div>
</fieldset>

HTML/CSS: Styling a checkbox inside a form

I have the following form:
Using this HTML:
<form id="user_form" name="user_form">
<input id="firstname" type="text" name="firstname" placeholder="Vorname" required>
<br>
<input id="lastname" type="text" name="lastname" placeholder="Nachname" required>
<br>
<input id="nickname" type="text" name="nickname" placeholder="Nickname" required>
<br>
<input id="email" type="email" name="email" placeholder="Email" required>
<br>
<input id="conditions" type="checkbox" name="conditions" required>Ich bin mit den <a id="show_2">Teilnahmebedingungen</a> einverstanden!
<br>
<input id="user_save" type="submit" value="Speichern">
</form>
And this CSS:
#user_form input[type="text"], input[type="email"], input[type="submit"] {
width: 80%;
display: block;
margin: 0 auto;
height: 50px !important;
font-size: 18px;
line-height: normal;
line-height: 32px\0/;
/* for IE 8 */
}
#user_form input[type="checkbox"] {
width: 80%;
display: inline !important;
margin: 0 !important;
padding: 0 !important;
height: 50px !important;
}
What i dont understand is:
Why isnt the checkbox aligned to the left. There should not be that padding to the left of the checkbox. i set margin and padding to 0.
Why is there so much space between the checkbox and the text right of the textbos? The Text needs to be directly to the right of the checkbox with maybe 20px padding. I also need that text to be centered vertically
Why is the text not linebreaking? the checkbox together with the text should have a width of 80% like all the other inputs.
Hope you can help me.
https://jsfiddle.net/p04prk6p/ here is what you need. Just layer a div around it
CSS
#user_form input[type="text"], input[type="email"], input[type="submit"] {
width: 80%;
display: block;
margin: 0 auto;
height: 50px !important;
font-size: 18px;
line-height: normal;
line-height: 32px\0/;
/* for IE 8 */
}
#user_form input[type="checkbox"] {
display: inline !important;
margin: 0 !important;
padding: 0 !important;
height: 50px !important;
float: left;
}
#checkbox_div {
width: 80%;
margin: 0 auto;
line-height: 50px;
}
HTML
<form id="user_form" name="user_form">
<input id="firstname" type="text" name="firstname" placeholder="Vorname" required>
<br>
<input id="lastname" type="text" name="lastname" placeholder="Nachname" required>
<br>
<input id="nickname" type="text" name="nickname" placeholder="Nickname" required>
<br>
<input id="email" type="email" name="email" placeholder="Email" required>
<br>
<div id="checkbox_div"><input id="conditions" type="checkbox" name="conditions" required>Ich bin mit den <a id="show_2">Teilnahmebedingungen</a> einverstanden!</div>
<br>
<div style="clear: both"></div>
<input id="user_save" type="submit" value="Speichern">
</form>
The problem you're having is that you have a width of 80% on your checkbox. This causes it to be moved to the right as well as pushing the text to the right.
Also don't use !important, it shouldn't be necessary in your case.
To make the alignment of your form inputs I'd suggest that you wrap them all and then leave them to the left. Instead of using 0 auto to center the inputs. Then your checkbox will align properly with the inputs. The way you're having it now, it never will whilst keeping the text exactly to the right.
#user_form input[type="text"], input[type="email"], input[type="submit"] { width: 80%; display: block; margin: 0 auto; height: 50px !important; font-size: 18px; line-height: normal; line-height: 32px\0/; /* for IE 8 */ }
.CheckBox{ width: 80%; text-align: center;}
<form id="user_form" name="user_form">
<input id="firstname" type="text" name="firstname" placeholder="Vorname" required>
<br>
<input id="lastname" type="text" name="lastname" placeholder="Nachname" required>
<br>
<input id="nickname" type="text" name="nickname" placeholder="Nickname" required>
<br>
<input id="email" type="email" name="email" placeholder="Email" required>
<br>
<p class="CheckBox"> <input id="conditions" type="checkbox" name="conditions" required>Ich bin mit den <a id="show_2">Teilnahmebedingungen</a> einverstanden!</p>
<br>
<input id="user_save" type="submit" value="Speichern">
</form>
#user_form input[type="text"], input[type="email"], input[type="submit"] {
width: 80%;
display: block;
margin: 0 auto;
height: 50px !important;
font-size: 18px;
line-height: normal;
line-height: 32px\0/;
/* for IE 8 */
}
#user_form input[type="checkbox"] {
width: 30px;
display: inline;
margin: 0;
padding: 0;
height: 50px;
}
<form id="user_form" name="user_form">
<input id="firstname" type="text" name="firstname" placeholder="Vorname" required>
<br>
<input id="lastname" type="text" name="lastname" placeholder="Nachname" required>
<br>
<input id="nickname" type="text" name="nickname" placeholder="Nickname" required>
<br>
<input id="email" type="email" name="email" placeholder="Email" required>
<br>
<input id="conditions" type="checkbox" name="conditions" required>Ich bin mit den <a id="show_2">Teilnahmebedingungen</a> einverstanden!
<br>
<input id="user_save" type="submit" value="Speichern">
</form>
Your problem is your width property. A check box has an Aspect Ratio 1:1. So give it a width of 30px will do the trick. 80% is really big
1: your input[type='checkbox'] contains a width of 80%, make it square size like 50px;
2: Same issue your input is 80% width of the parent and margin: 0 auto center it.
3: For linebreaks only work properly while using it in text like in a
<style>
#user_form input[type="text"], input[type="email"], input[type="submit"] {
width: 80%;
display: block;
margin: 0 auto;
height: 50px !important;
font-size: 18px;
line-height: normal;
line-height: 32px\0/;
/* for IE 8 */
}
label{
width: 100%;
float: left;
text-align: center;
margin: 20px 0px;
}
label > a{
color: #2a00ff;
z-index: 99999;
}
</style>
<form id="user_form" name="user_form">
<input id="firstname" type="text" name="firstname" placeholder="Vorname" required>
<br>
<input id="lastname" type="text" name="lastname" placeholder="Nachname" required>
<br>
<input id="nickname" type="text" name="nickname" placeholder="Nickname" required>
<br>
<input id="email" type="email" name="email" placeholder="Email" required>
<br>
<label>
<input id="conditions" type="checkbox" name="conditions" required>
Ich bin mit den <a id="show_2">Teilnahmebedingungen</a> einverstanden!
</label>
<br>
<input id="user_save" type="submit" value="Speichern">
</form>
Wrap your check box and label inside a div and give it a width of 80%. You can remove the padding and margin rules.
Height of the check box makes it to misalign with the text.
The text won't wrap because width is set to check box and not the text.
#user_form input[type="text"],
input[type="email"],
input[type="submit"] {
width: 80%;
display: block;
margin: 0 auto;
height: 50px !important;
font-size: 18px;
line-height: normal;
line-height: 32px\0/;
/* for IE 8 */
}
#user_form input[type="checkbox"] {
display: inline;
}
.checkbox {
margin: 0 auto;
width: 80%;
}
<form id="user_form" name="user_form">
<input type="text" id="firstname" name="firstname" placeholder="Vorname" required="">
<br>
<input type="text" id="lastname" name="lastname" placeholder="Nachname" required="">
<br>
<input type="text" id="nickname" name="nickname" placeholder="Nickname" required="">
<br>
<input type="email" id="email" name="email" placeholder="Email" required="">
<br>
<div class="checkbox">
<input type="checkbox" id="conditions" name="conditions" required="">
<label for "conditions"="">Ich bin mit den <a id="show_2">Teilnahmebedingungen</a> einverstanden!</label>
</div>
<br>
<input type="submit" id="user_save" value="Speichern">
</form>

Adding characters between input fields

I have a simple form with two columns and a field that consists of three inputs (see attached image)
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;
}
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/
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/