Align labels under input boxes using Bootstrap - html

I'm not sure how to go about getting the effect I want here. I have two input boxes that are on the same line and I want to have labels underneath them and aligned to match the respective input box.
<div class="container">
<form class="form-inline" role="form">
<div class="form-group">
<label for="decimal_input">Label 1</label>
<input type="text" value="1" width="10" id="decimal_input" class="form-control" />
= <label for="input2">Label 2</label>
<input type="text" value="I" width="30" id="input2" class="form-control" />
</div>
</div>
</form>
Take a look at the jsfiddle here for more info:
http://jsfiddle.net/justinhj/bTVKZ/2/

http://jsfiddle.net/isherwood/bTVKZ/6
<div class="container">
<form class="form-inline" role="form">
<div class="form-group">
<div class="pull-left">
<input type="text" value="1" width="10" id="decimal_input" class="form-control" />
<br />
<label for="decimal_input">Label 1</label>
</div>
<div>
<input type="text" value="I" width="30" id="input2" class="form-control" />
<br />
<label for="input2">Label 2</label>
</div>
</div>
</form>
</div>

Your new HTML:
<div class="container">
<form class="form-inline" role="form">
<div class="form-group">
<span class="inner-container">
<label for="decimal_input">Label 1</label>
<input type="text" value="1" width="10" id="decimal_input" class="form-control" />
</span>
=
<span class="inner-container">
<label for="input2">Label 2</label>
<input type="text" value="I" width="30" id="input2" class="form-control" />
</span>
</div>
</div>
</form>
</diV>
Your new CSS (of course I would add a class to the labels):
.container {
margin-top: 10px;
}
.inner-container {
position: relative;
}
label {
top: 25px;
left: 5px;
position: absolute;
}
here's the fiddle

You may try this
Extra CSS:
label {
display:block;
}
.form-group {
display:inline-block;
}
Modified HTML:
<div class="container">
<form class="form-inline" role="form">
<div class="form-group">
<input type="text" value="1" width="10" id="decimal_input" class="form-control" />
<label for="decimal_input">Label 1</label>
</div>
<div class="form-group">
<input type="text" value="I" width="30" id="input2" class="form-control" />
<label for="input2">Label 2</label>
</div>
</form>
</div>
DEMO.

Related

How to display html form next to each other and in rows?

I am currently trying to get two forms next to each other and then two more forms under it all aligned. If anyone has any suggestions to help me out that would be great. Here is my source code in a jsfiddle.
I am trying to get the name and company input next to each other and then the phone and email below it with the comment textbox at the base. I was trying the 40% width and it sort of helped to get the first row. I was thinking of going the table route as I could probably get that working fine for the forms being aligned but I know tables is not the correct route for coding this.
https://jsfiddle.net/xtwistedmetal/two7hgtm/1/
or
<style type="text/css">
#mc_embed_signup {
background: #fff;
clear: left;
font: 14px Helvetica, Arial, sans-serif;
}
.mc-field-group1 {
display: inline-block;
width: 40%;
}
.mc-field-group2 {
display: inline-block;
}
</style>
<div id="mc_embed_signup">
<form method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate="" action="websitehere">
<div id="mc_embed_signup_scroll">
<div align="center">
<h2> Wholesale Contact Form</h2>
</div>
<div class="mc-field-group1">
<label for="mce-FNAME">Name </label>
<input type="text" value="" name="FNAME" class="required" id="mce-FNAME" />
</div>
<div class="mc-field-group1">
<label for="mce-MMERGE3">Company Name </label>
<input type="text" value="" name="MMERGE3" class="required" id="mce-MMERGE3" />
</div>
<div class="mc-field-group2">
<label for="mce-EMAIL">Email Address </label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL" />
</div>
<br>
<div class="mc-field-group2">
<label for="mce-MMERGE2">Phone Number </label>
<input type="text" name="MMERGE2" class="" value="" id="mce-MMERGE2" />
</div>
<div class="mc-field-group">
<label for="mce-COMMENTS">Comments </label>
<!-- <input type="text" value="" name="COMMENTS" class="required" id="mce-COMMENTS" /> -->
<textarea id="mce-COMMENTS" name="COMMENTS" cols="47" rows="3"> </textarea>
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display: none;"></div>
<div class="response" id="mce-success-response" style="display: none;"></div>
</div>
<div class="clear" align="center">
<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button" />
</div>
</div>
</form>
</div>
You can try an approach like below
.form-group:after{
content: "";
display:table;
clear:both;
}
.form-group-half{
width:44%;
padding:0 3%;
float:left;
}
.form-group-half > label{
display:block;
}
.form-group-half > input,
.form-group-half > select,
.form-group-half > textarea {
width:100%;
}
<div class="form-group">
<div class="form-group-half">
<label>Field 1</label>
<input type="text" name="field1">
</div>
<div class="form-group-half">
<label>Field 2</label>
<input type="text" name="field2">
</div>
</div>
<div class="form-group">
<div class="form-group-half">
<label>Field 3</label>
<input type="text" name="field3">
</div>
<div class="form-group-half">
<label>Field 4</label>
<input type="text" name="field4">
</div>
</div>
HTML ;
<div id="mc_embed_signup">
<form method="post" id="mc-embedded-subscribe-form" name="mc-embedded-subscribe-form" class="validate" target="_blank" novalidate="" action="websitehere">
<div id="mc_embed_signup_scroll">
<div align="center">
<h2> Wholesale Contact Form</h2>
</div>
<div class="mc-field-group1" style=>
<div style="width:40%">
<label for="mce-FNAME">Name </label>
<input type="text" value="" name="FNAME" class="required" id="mce-FNAME" />
</div>
<div style="width:40%">
<label for="mce-MMERGE3">Company Name </label>
<input type="text" value="" name="MMERGE3" class="required" id="mce-MMERGE3" />
</div>
</div>
<div class="mc-field-group2">
<div style="width:40%">
<label for="mce-EMAIL">Email Address </label>
<input type="email" value="" name="EMAIL" class="required email" id="mce-EMAIL" />
</div>
<div style="width:40%">
<label for="mce-MMERGE2">Phone Number </label>
<input type="text" name="MMERGE2" class="" value="" id="mce-MMERGE2" />
</div>
</div>
<br>
<div class="mc-field-group">
<label for="mce-COMMENTS">Comments </label>
<!-- <input type="text" value="" name="COMMENTS" class="required" id="mce-COMMENTS" /> -->
<textarea id="mce-COMMENTS" name="COMMENTS" cols="47" rows="3"> </textarea>
</div>
<div id="mce-responses" class="clear">
<div class="response" id="mce-error-response" style="display: none;"></div>
<div class="response" id="mce-success-response" style="display: none;"></div>
</div>
<div class="clear" align="center">
<input type="submit" value="Subscribe" name="subscribe" id="mc-embedded-subscribe" class="button" />
</div>
</div>
</form>
</div>
CSS
<style type="text/css">
#mc_embed_signup {
background: #fff;
clear: left;
font: 12px Helvetica, Arial, sans-serif;
}
.mc-field-group1 {
width: 100%;
display: inline-flex;
}
.mc-field-group2 {
display: inline-flex;
width: 100%;
}
label{
color:red;
width:40px !important;
}

Bootstrap, Two columns won't go side by side (Form + Message)

I'm trying to make a contact section with two columns, an lg-8 and lg-3 (EDIT) + 1 buffer column:
First Column: Contact Form
Second Column: A simple text message from me.
I've looked around several places and cannot understand what is wrong with my code. I've done everything [bootstrap][1] resource says to and I'm getting one column underneath the other.
This is in a 'div class="container"'
<div class="formattedContact" id="contact">
<h3>Contact Me</h3>
<div class="wrapper">
<div class="content-main">
<form id="contactForm">
<form class="form-item">
<label for="inputName" ></label>
<input type="text" name="name" placeholder="Name" width="100%"></input>
</form>
<form class="form-item">
<label for="inputEmail" ></label>
<input type="text" name="email" placeholder="Email" width="100%"></input>
</form>
<form class="form-item">
<label for="inputPhone" ></label>
<input type="text" name="phone" placeholder="Phone" width="100%"></input>
</form>
<form class="form-item">
<label for="inputMsg" >Message</label><br>
<textarea rows='5' placeholder='Message' > </textarea>
</form>
<button type="submit">Send</button>
</form>
</div>
<div class="content-secondary">
<p>Hullo, Shoot me a text</p>
</div>
</div>
</div>
and the CSS
.wrapper {
.make-row();
}
.content-main {
.make-lg-column(8);
}
.content-secondary {
.make-lg-column(3);
.make-lg-column-offset(1);
}
I made several changes, both to get it to work as you describe and to get the labels linked to the inputs. It is a little redundant to have the placeholders match the labels, but you can do what you want to with that. You can change the 'xs' back to 'lg' in the grid class names, so they will be more appropriate outside of a small snippet. You may find that you want something in between, such as 'sm', (ex 'col-sm-8') since the classes take effect for the size specified between the dashes and larger.
Also, you know that the width numbers at the end of these bootstrap grid system class names are typically supposed to add up to 12, not 11 for a given screen width specifier, right?
#contactForm label {
display: block;
}
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<script src="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js"></script>
<link href="http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css" rel="stylesheet"/>
<div class="container">
<div class="formattedContact" id="contact">
<h3>Contact Me</h3>
<div class="wrapper">
<div class="content-main">
<form id="contactForm" class="col-xs-8">
<label for="inputName" >Name</label>
<input type="text" name="inputName" placeholder="Name" width="100%">
<label for="inputEmail" >Email</label>
<input type="text" name="inputEmail" placeholder="Email" width="100%">
<label for="inputPhone" >Phone</label>
<input type="text" name="inputPhone" placeholder="Phone" width="100%">
<label for="inputMsg" >Message</label>
<textarea rows='5' placeholder='Message' name="inputMsg" > </textarea>
<button type="submit">Send</button>
</form>
</div>
<div class="content-secondary col-xs-3">
<p>Hullo, Shoot me a text</p>
</div>
</div>
</div>
</div>
Add the following (Although I would recommend adding an id to these divs and styling )
.content-secondary,.content-main{
display:inline-block;
vertical-align:bottom
}
Snippet below
.wrapper {
.make-row();
}
.content-main {
.make-lg-column(8);
}
.content-secondary {
.make-lg-column(3);
.make-lg-column-offset(1);
}
.content-secondary,
.content-main {
display: inline-block;
vertical-align: bottom
}
<div class="formattedContact" id="contact">
<h3>Contact Me</h3>
<div class="wrapper">
<div class="content-main">
<form id="contactForm">
<form class="form-item">
<label for="inputName"></label>
<input type="text" name="name" placeholder="Name" width="100%"></input>
</form>
<form class="form-item">
<label for="inputEmail"></label>
<input type="text" name="email" placeholder="Email" width="100%"></input>
</form>
<form class="form-item">
<label for="inputPhone"></label>
<input type="text" name="phone" placeholder="Phone" width="100%"></input>
</form>
<form class="form-item">
<label for="inputMsg">Message</label>
<br>
<textarea rows='5' placeholder='Message'></textarea>
</form>
<button type="submit">Send</button>
</form>
</div>
<div class="content-secondary">
<p>Hullo, Shoot me a text</p>
</div>
</div>
</div>
Use the built in row and column classes:
<div class="container">
<div class="row">
<div class="col-sm-8">
<div class="formattedContact" id="contact">
<h3>Contact Me</h3>
<div class="wrapper">
<div class="content-main">
<form id="contactForm">
<form class="form-item">
<label for="inputName" ></label>
<input type="text" name="name" placeholder="Name" width="100%"></input>
</form>
<form class="form-item">
<label for="inputEmail" ></label>
<input type="text" name="email" placeholder="Email" width="100%"></input>
</form>
<form class="form-item">
<label for="inputPhone" ></label>
<input type="text" name="phone" placeholder="Phone" width="100%"></input>
</form>
<form class="form-item">
<label for="inputMsg" >Message</label><br>
<textarea rows='5' placeholder='Message' > </textarea>
</form>
<button type="submit">Send</button>
</form>
</div>
</div>
<div class="col-sm-3">
<div class="content-secondary">
<p>Hullo, Shoot me a text</p>
</div>
</div>
</div>
</div>
Add float:left to your content-main
.content-main {
.make-lg-column(8);
float:left;
}
https://jsfiddle.net/9Lf16p1c/

Inputs order in the form with Booststrap

I have problem with setting right order of inputs in the form on the mobile view using Bootstrap. I already asked similar question, and got some tips and have been told is easy. I tried many things and i just don't know how to get required result.
Take a look at the jsfiddle please.
https://jsfiddle.net/nitadesign/y79LwL9x/8/
I want input with placeholder (17 - Error Text Area) to be on the top of the (20 - Button).
Visual graph:
And HTML
<div class="row">
<div class="col-md-3">
<input name="textinput" type="text" placeholder="1" class="form-control" />
<input name="textinput" type="text" placeholder="2" class="form-control" />
<input name="textinput" type="text" placeholder="3" class="form-control" />
<input name="textinput" type="text" placeholder="4" class="form-control" />
<input name="textinput" type="text" placeholder="5" class="form-control" />
</div>
<div class="col-md-6">
<div class="row">
<div class="col-md-6">
<input name="textinput" type="text" placeholder="6" class="form-control" />
<input name="textinput" type="text" placeholder="7" class="form-control" />
<input name="textinput" type="text" placeholder="8" class="form-control" />
<input name="textinput" type="text" placeholder="9" class="form-control" />
</div>
<div class="col-md-6">
<input name="textinput" type="text" placeholder="10" class="form-control" />
<input name="textinput" type="text" placeholder="11" class="form-control" />
<input name="textinput" type="text" placeholder="12" class="form-control" />
<input name="textinput" type="text" placeholder="13" class="form-control" />
</div>
</div>
</div>
<div class="col-md-3">
<input name="textinput" type="text" placeholder="14" class="form-control" />
<input name="textinput" type="text" placeholder="15" class="form-control" />
<input name="textinput" type="text" placeholder="16" class="form-control" />
<input name="textinput" type="text" placeholder="17 - Error Text Area" class="form-control" />
</div>
<div class="col-md-9">
<div class="row">
<div class="col-md-4">
<input name="textinput" type="text" placeholder="18" class="form-control" />
</div>
<div class="col-md-4">
<input name="textinput" type="text" placeholder="19" class="form-control" />
</div>
<div class="col-md-4">
<input name="textinput" type="text" placeholder="20 - Button" class="form-control" />
</div>
</div>
</div>
</div>
...got some tips and have been told is easy.
I'm with you, it wasn't that easy. If it was that easy you would've gotten an answer that works.
SOLUTION
You can use flexbox on inputs 17 to 20 and use the flexbox property order.
.flex { display: flex; flex-direction: column; }
.flex1 { order:3; }
.flex2 { order:1; }
.flex3 { order:2; }
.flex4 { order:4; }
#media screen and (min-width:1000px) {
.flex { display: inline; }
}
These rulesets basically are saying:
The 4 designated flex items (children of a flex container, i.e. .flex1, .flex2, .flex3, .flex4) will be reordered as:
3rd is now 1st,
1st is now 2nd,
and 2nd is now 3rd
When the viewport is wider than 1000px, the flex container (i.e. .flex) will be a harmless inline element.
In order to make the styles work without disrupting the layout, there had to be some changes to the HTML:
Wrapped <span class='flex'> around inputs 17 to 20.
Assigned classes .flex1, .flex2, .flex3, .flex4 to inputs 17 to 20.
The last 3 divs classes changed from .col-md-4 to .col-md-3.
Removed .col-md-9 and .row that was wrapped around inputs 18 to 20.
Moved input 17 inside .flex and wrapped a <div class='col-md-3'> around it.
PLUNKER
SNIPPET
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
<style>
.flex {
display: flex;
flex-direction: column;
}
.flex1 {
order: 3;
}
.flex2 {
order: 1;
}
.flex3 {
order: 2;
}
.flex4 {
order: 4;
}
#media screen and (min-width: 1000px) {
.flex {
display: inline;
}
}
</style>
</head>
<body>
<div class="row">
<div class="col-md-3">
<input name="textinput" type="text" placeholder="1" class="form-control" />
<input name="textinput" type="text" placeholder="2" class="form-control" />
<input name="textinput" type="text" placeholder="3" class="form-control" />
<input name="textinput" type="text" placeholder="4" class="form-control" />
<input name="textinput" type="text" placeholder="5" class="form-control" />
</div>
<div class="col-md-6">
<div class="row">
<div class="col-md-6">
<input name="textinput" type="text" placeholder="6" class="form-control" />
<input name="textinput" type="text" placeholder="7" class="form-control" />
<input name="textinput" type="text" placeholder="8" class="form-control" />
<input name="textinput" type="text" placeholder="9" class="form-control" />
</div>
<div class="col-md-6">
<input name="textinput" type="text" placeholder="10" class="form-control" />
<input name="textinput" type="text" placeholder="11" class="form-control" />
<input name="textinput" type="text" placeholder="12" class="form-control" />
<input name="textinput" type="text" placeholder="13" class="form-control" />
</div>
</div>
</div>
<div class="col-md-3">
<input name="textinput" type="text" placeholder="14" class="form-control" />
<input name="textinput" type="text" placeholder="15" class="form-control" />
<input name="textinput" type="text" placeholder="16" class="form-control" />
</div>
<span class='flex'>
<div class="col-md-3 flex1">
<input name="textinput" type="text" placeholder="17 - Error Text Area" class="form-control" />
</div>
<div class="col-md-3 flex2">
<input name="textinput" type="text" placeholder="18" class="form-control" />
</div>
<div class="col-md-3 flex3">
<input name="textinput" type="text" placeholder="19" class="form-control" />
</div>
<div class="col-md-3 flex4">
<input name="textinput" type="text" placeholder="20 - Button" class="form-control" />
</div>
</span>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
</body>
</html>

responsive position of a form

I am trying to position my form box. To see where I was going I just made some inline style. It is also looking like I want on the desktop version, but when I see it on mobile version the form box is out of the picture.
If I made the Inline CSS in an external stylesheet, and made a Mediaquery, it would not be the correct way to do it, would it? For me it seems like bad practice?
<!-- Content -->
<div class="container-fluid">
<div class="row">
<div class="col-lg-12" style="width:25%; top: 70px; left: 1000px;">
#Umbraco.RenderMacro("Ebook")
</div>
</div>
</div>
<div class="sign-up">
<form id="ebog-trin-for-trin">
<div class="form-group">
<label class="sr-only" for="name">Navn</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Navn" required/>
</div>
<div class="form-group">
<label class="sr-only" for="lastname">Efternavn</label>
<input type="text" class="form-control" id="lastname" name="lastname" placeholder="Efternavn" required/>
</div>
<div class="form-group">
<label class="sr-only" for="email">E-mail</label>
<input type="email" class="form-control" id="email" name="email" placeholder="E-mail" required />
</div>
<div class="form-group">
<label class="sr-only" for="phone">Telefon</label>
<input type="text" class="form-control" id="phone" name="phone" placeholder="Telefonnummer" required />
</div>
<div class="form-group">
<label class="sr-only" for="company">Virksomhed</label>
<input type="text" class="form-control" id="company" name="company" placeholder="Virksomhed" required/>
</div>
<input type="text" id="Channel" name="Channel" style="display: none;" />
<input type="text" id="Campaign" name="Campaign" style="display: none;" />
<button type="submit" class="btn btn-default active">Hent E-bogen</button>
</form>
</div>
Here's an example with the form floating to the right for larger screens, and showing full-width for smaller screens.
.floating-form {
background: #eee;
float: right;
padding: 20px 0;
width: 320px;
}
#media (max-width: 479px) {
.floating-form {
float: none;
width: auto;
}
}
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />
<div class="floating-form">
<div class="container-fluid">
<div class="row">
<div class="sign-up col-xs-12">
<form id="ebog-trin-for-trin">
<div class="form-group">
<label class="sr-only" for="name">Navn</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Navn" required/>
</div>
<div class="form-group">
<label class="sr-only" for="lastname">Efternavn</label>
<input type="text" class="form-control" id="lastname" name="lastname" placeholder="Efternavn" required/>
</div>
<div class="form-group">
<label class="sr-only" for="email">E-mail</label>
<input type="email" class="form-control" id="email" name="email" placeholder="E-mail" required />
</div>
<div class="form-group">
<label class="sr-only" for="phone">Telefon</label>
<input type="text" class="form-control" id="phone" name="phone" placeholder="Telefonnummer" required />
</div>
<div class="form-group">
<label class="sr-only" for="company">Virksomhed</label>
<input type="text" class="form-control" id="company" name="company" placeholder="Virksomhed" required/>
</div>
<input type="text" id="Channel" name="Channel" style="display: none;" />
<input type="text" id="Campaign" name="Campaign" style="display: none;" />
<button type="submit" class="btn btn-default active">Hent E-bogen</button>
</form>
</div>
</div>
</div>
</div>
<!-- Content -->
<div class="container-fluid">
<div class="row">
<div class="col-xs-6 col-md-6 col-lg-6">
#Umbraco.RenderMacro("Ebook")
</div>
<div class="sign-up col-xs-6 col-md-6 col-lg-6">
<form id="ebog-trin-for-trin">
<div class="form-group">
<label class="sr-only" for="name">Navn</label>
<input type="text" class="form-control" id="name" name="name" placeholder="Navn" required/>
</div>
<div class="form-group">
<label class="sr-only" for="lastname">Efternavn</label>
<input type="text" class="form-control" id="lastname" name="lastname" placeholder="Efternavn" required/>
</div>
<div class="form-group">
<label class="sr-only" for="email">E-mail</label>
<input type="email" class="form-control" id="email" name="email" placeholder="E-mail" required />
</div>
<div class="form-group">
<label class="sr-only" for="phone">Telefon</label>
<input type="text" class="form-control" id="phone" name="phone" placeholder="Telefonnummer" required />
</div>
<div class="form-group">
<label class="sr-only" for="company">Virksomhed</label>
<input type="text" class="form-control" id="company" name="company" placeholder="Virksomhed" required/>
</div>
<input type="text" id="Channel" name="Channel" style="display: none;" />
<input type="text" id="Campaign" name="Campaign" style="display: none;" />
<button type="submit" class="btn btn-default active">Hent E-bogen</button>
</form>
</div>
</div>
</div>
Fiddle
This Will Useful for you..

How to render no-table HTML form into two columns with CSS using classes?

I am trying to format a two-column form so that:
the labels are above each input field or text area
everything in class col1 is in the column on the left
everything in class col2 is in the column on the right
everything in class col12 spans both columns
Here is the HTML code I need this to work with:
<div id="contactForm">
<form method="post" action="">
<h3>Contact us</h3>
<p>To send us a work order, fill in the form below.<br /><strong>All the (*) fields are mandatory.</strong></p>
<fieldset>
<div class="col1">
<label for="form_firstname">Firstname <span class="required">*</span></label>
<input type="text" id="form_firstname" name="form_firstname" value="" />
</div>
<div class="col2">
<label for="form_lastname">Lastname <span class="required">*</span></label>
<input type="text" id="form_lastname" name="form_lastname" value="" />
</div>
<div class="col1">
<label for="form_address">Address</label>
<input type="text" id="form_address" name="form_address" value="" />
</div>
<div class="col2">
<label for="form_city">City</label>
<input type="text" id="form_city" name="form_city" value="" />
</div>
<div class="col1">
<label for="form_email">Email <span class="required">*</span></label>
<input type="text" id="form_email" name="form_email" value="" />
</div>
<div class="col2">
<label for="form_phone">Phone <span class="required">*</span></label>
<input type="text" id="form_phone" name="form_phone" value="" />
</div>
<div class="col12">
<label for="form_attachment">Add Attachment <span class="form_attachment">*</span></label>
<textarea id="form_attachment" name="form_attachment" rows="5"></textarea>
</div>
<div class="col12">
<label for="form_message">Message <span class="required">*</span></label>
<textarea id="form_message" name="form_message" rows="5"></textarea>
</div>
<div class="col12">
<label for="form_message">Message <span class="required">*</span></label>
<input type="submit" value="Send" formnovalidate="formnovalidate" />
</div>
</fieldset>
</form>
</div>
How do I code the CSS to style this HTML as required?
Here is the code on JSFiddle.
Try this CSS:
#contactForm{
width: 80%;
}
label,.col1,.col2,.col12{display: block;}
.col1{ float:right;}
.col2{float:left;}
.col12{clear:both;}
textarea{
display: block;
width: 100%;
}
http://jsfiddle.net/rx2gjpdw/3/