How can I create a responsive side by side form? - html

I'm looking for the best way to go about a side by side form.
I've done mine in a responsive grid which apparently isn't viable as I am using two separate form tags.
Here is what I've come up with so far.
http://jsfiddle.net/pentester/aFP68/
Any Help Would be greatly appreciated.
<div class="section group">
<div class="col span_1_of_2">
<div class="formwrap">
<form method="post" action="contact.php">
<input type="text" name="name" id="name" placeholder="Name" required />
<input type="text" name="company" id="company" placeholder="Company" required />
<input type="text" name="email" id="email" placeholder="Email" required />
<input type="text" name="phone" id="phone" placeholder="Phone Number" required />
<p class="submit">
<input id="submit" name="submit" type="submit" value="Send" />
</p>
</form>
</div>
</div>
<div class="col span_1_of_2">
<div class="formwrap">
<form method="post" action="contact.php">
<select name="new_or_upgrade" id="new_or_upgrade" placeholder="Type of website">
<option value="Type">Type of website</option>
<option value="normal">Normal</option>
<option value="cms">Content Management Site</option>
<option value="upgrade">E Commerce</option>
</select>
<textarea name="message" placeholder="Tell us about your project" required /></textarea>
</form>
</div>
</div>
/*Form*/
select{
width:100%;
padding:0.5em;
border:1px solid #F2F2F2;
margin-top: 0.5em;}
.formwrap {
margin: auto;
max-width: 70em;
padding: 0 0.5em;
}
.formwrap p {
font-family: sans;
font-weight: 100;
font-size: 1em;
margin: 0;
}
form {
clear: both;
float: left;
width: 100%;
margin: 0 auto;
}
input,
textarea {
padding: 10px;
border: 1px solid #EFEFEF;
width: 100%;
color: #000;
margin-top: 0.5em;
border-radius:3px;
}
textarea {
width: 100%;
height: 150px;
line-height: 18px;
}
input:focus,
textarea:focus {
border: 1px solid #21ABD3;
transition: all 0.2s ease;
}
form label {
margin-left: 1em;
color: #000;
}
.submit input {
background-color: #1D8FBB;
width: 6em;
color: #FFF;
box-shadow: 0 1px 0 rgba(255, 255, 255, 0.2) inset;
border: none;
float: left;
transition: none;
border-radius: 3px;
font-family:opensans
}
.submit input:hover {
background-color: #34A2CD;
transition: all 0.2s ease;
}
.submit input:active {
box-shadow: 0 0 3px rgba(51, 51, 51, 0.61) inset;
}
/* SECTIONS */
.section {
clear: both;
padding: 0px;
margin: 0px;
}
/* COLUMN SETUP */
.col {
display: block;
float: left;
margin: 1% 0 1% 1%;
}
.col:first-child {
margin-left: 0;
}
/* GROUPING */
.group:before,
.group:after {
content: "";
display: table;
}
.group:after {
clear: both;
}
.group {
zoom: 1; /* For IE 6/7 */
}
/* GRID OF TWO */
.span_2_of_2 {
width: 100%;
}
.span_1_of_2 {
width: 49.5%;
}
/* GO FULL WIDTH AT LESS THAN 600 PIXELS */
#media only screen and (max-width: 800px) {
.col {
margin: 0;
}
}
#media only screen and (max-width: 800px) {
.span_2_of_2 {
width: 100%;
}
.span_1_of_2 {
width: 100%;
}
}
#media only screen and (max-width: 600px) {
.block{
padding:0.5em 1em}
}

There are a lot of way to create responsive layout. For me, I would like to use Bootstrap.
http://jsfiddle.net/wrcuv/
Here is the example,
<link rel="stylesheet" type="text/css" href="http://maxcdn.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css" />
<div class="container">
<form method="post" action="contact.php" class="form">
<div class="row">
<div class="col-sm-6">
<div class="form-group">
<input type="text" name="name" id="name" placeholder="Name" class="form-control" required />
</div>
<div class="form-group">
<input type="text" name="company" id="company" placeholder="Company" class="form-control" required />
</div>
<div class="form-group">
<input type="text" name="email" id="email" placeholder="Email" class="form-control" required />
</div>
<div class="form-group">
<input type="text" name="phone" id="phone" placeholder="Phone Number" class="form-control" required />
</div>
</div>
<div class="col-sm-6">
<div class="form-group">
<select name="new_or_upgrade" id="new_or_upgrade" class="form-control" placeholder="Type of website">
<option value="Type">Type of website</option>
<option value="normal">Normal</option>
<option value="cms">Content Management Site</option>
<option value="upgrade">E Commerce</option>
</select>
</div>
<div class="form-group">
<textarea name="message" placeholder="Tell us about your project" class="form-control" required /></textarea>
</div>
</div>
</div>
<div class="row text-center">
<input id="submit" name="submit" type="submit" value="Send" class="btn btn-primary" />
</div>
</form>
</div>

Related

Bootstrap 4 form fields not aligning horizontally

I am writing a signup form using Bootstrap 4. I can't get the form fields for user image and biography, to align with the rest of the form fields.
I have tweaked the CSS several ways, but can't get the visual effect I want, which is:
Biography and photo upload fields be same width as all form fields, and align horizontally
Photo field split into two equal width sections (a bit like first and last name fields), with uploaded image horizontally aligned in one field, and the button horizontally aligned in a second field.
Here is my code:
body {
color: #fff;
background: #63738a;
font-family: 'Roboto', sans-serif;
}
.form-control {
height: 40px;
box-shadow: none;
color: #969fa4;
}
.form-control:focus {
border-color: #5cb85c;
}
.form-control,
.btn {
border-radius: 3px;
}
.signup-form {
width: 450px;
margin: 0 auto;
padding: 30px 0;
font-size: 15px;
}
.signup-form h2 {
color: #636363;
margin: 0 0 15px;
position: relative;
text-align: center;
}
.signup-form h2:before,
.signup-form h2:after {
content: "";
height: 2px;
width: 30%;
background: #d4d4d4;
position: absolute;
top: 50%;
z-index: 2;
}
.signup-form h2:before {
left: 0;
}
.signup-form h2:after {
right: 0;
}
.signup-form .hint-text {
color: #999;
margin-bottom: 30px;
text-align: center;
}
.signup-form form {
color: #999;
border-radius: 3px;
margin-bottom: 15px;
background: #f2f3f7;
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
padding: 30px;
}
.signup-form .form-group {
margin-bottom: 20px;
}
.signup-form input[type="checkbox"] {
margin-top: 3px;
}
.signup-form .btn {
font-size: 16px;
font-weight: bold;
min-width: 140px;
outline: none !important;
}
.signup-form .row div:first-child {
padding-right: 10px;
}
.signup-form .row div:last-child {
padding-left: 10px;
}
.signup-form a {
color: #fff;
text-decoration: underline;
}
.signup-form a:hover {
text-decoration: none;
}
.signup-form form a {
color: #5cb85c;
text-decoration: none;
}
.signup-form form a:hover {
text-decoration: underline;
}
.img-profile {
width: 120px;
height: 120px;
margin-bottom: 15px
}
.avatar .figure img {
float: right;
width: 64px
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,700">
<title>Bootstrap Simple Registration Form</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="signup-form">
<form action="#" method="post">
<h2>Create Account</h2>
<div class="form-group">
<div class="row">
<div class="col"><input type="text" class="form-control" name="first_name" placeholder="First Name" required="required"></div>
<div class="col"><input type="text" class="form-control" name="last_name" placeholder="Last Name" required="required"></div>
</div>
</div>
<div class="form-group">
<input type="text" class="form-control" name="screenname" placeholder="Username" required="required">
</div>
<div class="form-group avatar">
<div class="row">
<figure class="figure col-md-2 col-sm-3 col-xs-12">
<img class="img-rounded img-responsive" src="https://bootdey.com/img/Content/avatar/avatar1.png" alt="">
</figure>
<div class="form-inline col-md-10 col-sm-9 col-xs-12">
<input type="file" class="file-uploader pull-left">
<button type="submit" class="btn btn-sm btn-default-alt pull-left">Update Image</button>
</div>
</div>
</div>
<div class="form-group">
<label for="user-bio" class="col-lg-2 control-label">Biography</label>
<div class="col-lg-10">
<textarea name="user-bio" id="user-bio" class="form-control" cols="20" rows="3" placeholder="Brief biography"></textarea>
</div>
</div>
<div class="form-group">
<input type="password" class="form-control" name="password" placeholder="Password" required="required">
</div>
<div class="form-group">
<input type="password" class="form-control" name="confirm_password" placeholder="Confirm Password" required="required">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success btn-lg btn-block">Create Account Now</button>
</div>
</form>
</div>
</body>
</html>
How do I fix the alignment issue in the form?
Step 1 is usually to strip out all the custom margins and padding you've applied. They're usually not necessary with Bootstrap, and they tend to cause problems.
Then wrap the entire thing with a container and set a max-width on it:
body {
color: #fff;
background: #63738a;
font-family: 'Roboto', sans-serif;
}
.form-control {
height: 40px;
box-shadow: none;
color: #969fa4;
}
.form-control:focus {
border-color: #5cb85c;
}
.form-control,
.btn {
border-radius: 3px;
}
.signup-form {
font-size: 15px;
max-width: 450px;
}
.signup-form h2 {
color: #636363;
position: relative;
text-align: center;
}
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.css"/>
<div class="container signup-form">
<form action="#" method="post">
<h2>Create Account</h2>
<div class="form-group">
<div class="row">
<div class="col"><input type="text" class="form-control" name="first_name" placeholder="First Name" required="required"></div>
<div class="col"><input type="text" class="form-control" name="last_name" placeholder="Last Name" required="required"></div>
</div>
</div>
<div class="form-group">
<input type="text" class="form-control" name="screenname" placeholder="Username" required="required">
</div>
<div class="form-group avatar">
<div class="row">
<figure class="figure col col-md-2 col-sm-3">
<img class="img-rounded img-responsive" src="https://bootdey.com/img/Content/avatar/avatar1.png" alt="">
</figure>
<div class="form-inline col-md-10 col-sm-9 col-xs-12">
<input type="file" class="file-uploader pull-left">
<button type="submit" class="btn btn-sm btn-default-alt pull-left">Update Image</button>
</div>
</div>
</div>
<div class="form-group">
<label for="user-bio" class="control-label">Biography</label>
<textarea name="user-bio" id="user-bio" class="form-control" cols="20" rows="3" placeholder="Brief biography"></textarea>
</div>
<div class="form-group">
<input type="password" class="form-control" name="password" placeholder="Password" required="required">
</div>
<div class="form-group">
<input type="password" class="form-control" name="confirm_password" placeholder="Confirm Password" required="required">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success btn-lg btn-block">Create Account Now</button>
</div>
</form>
</div>
change the width and remove the float
body {
color: #fff;
background: #63738a;
font-family: 'Roboto', sans-serif;
}
.form-control {
height: 40px;
box-shadow: none;
color: #969fa4;
}
.form-control:focus {
border-color: #5cb85c;
}
.form-control,
.btn {
border-radius: 3px;
}
.signup-form {
width: 450px;
margin: 0 auto;
padding: 30px 0;
font-size: 15px;
}
.signup-form h2 {
color: #636363;
margin: 0 0 15px;
position: relative;
text-align: center;
}
.signup-form h2:before,
.signup-form h2:after {
content: "";
height: 2px;
width: 30%;
background: #d4d4d4;
position: absolute;
top: 50%;
z-index: 2;
}
.signup-form h2:before {
left: 0;
}
.signup-form h2:after {
right: 0;
}
.signup-form .hint-text {
color: #999;
margin-bottom: 30px;
text-align: center;
}
.signup-form form {
color: #999;
border-radius: 3px;
margin-bottom: 15px;
background: #f2f3f7;
box-shadow: 0px 2px 2px rgba(0, 0, 0, 0.3);
padding: 30px;
}
.signup-form .form-group {
margin-bottom: 20px;
}
.signup-form input[type="checkbox"] {
margin-top: 3px;
}
.signup-form .btn {
font-size: 16px;
font-weight: bold;
min-width: 140px;
outline: none !important;
}
.signup-form .row div:first-child {
padding-right: 10px;
}
.signup-form .row div:last-child {
padding-left: 10px;
}
.signup-form a {
color: #fff;
text-decoration: underline;
}
.signup-form a:hover {
text-decoration: none;
}
.signup-form form a {
color: #5cb85c;
text-decoration: none;
}
.signup-form form a:hover {
text-decoration: underline;
}
.img-profile {
width: 120px;
height: 120px;
margin-bottom: 15px
}
/* code */
/* for image */
.avatar .figure img {
width: 64px;
}
/* for choose file input */
.pull-left {
float: left;
width: 138px;
margin-left: -26px;
}
/* for biography */
textarea.form-control {
/* height: auto; */
margin-left: -15px;
width: 390px;
}
/* upload button */
.btn:not(:disabled):not(.disabled) {
cursor: pointer;
margin-left: 38px;
padding-left: 22px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:400,700">
<title>Bootstrap Simple Registration Form</title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css">
<script src="https://code.jquery.com/jquery-3.5.1.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/popper.js#1.16.0/dist/umd/popper.min.js"></script>
<script src="https://stackpath.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
</head>
<body>
<div class="signup-form">
<form action="#" method="post">
<h2>Create Account</h2>
<div class="form-group">
<div class="row">
<div class="col"><input type="text" class="form-control" name="first_name" placeholder="First Name" required="required"></div>
<div class="col"><input type="text" class="form-control" name="last_name" placeholder="Last Name" required="required"></div>
</div>
</div>
<div class="form-group">
<input type="text" class="form-control" name="screenname" placeholder="Username" required="required">
</div>
<div class="form-group avatar">
<div class="row">
<figure class="figure col-md-2 col-sm-3 col-xs-12">
<img class="img-rounded img-responsive" src="https://bootdey.com/img/Content/avatar/avatar1.png" alt="">
</figure>
<div class="form-inline col-md-10 col-sm-9 col-xs-12">
<input type="file" class="file-uploader pull-left">
<button type="submit" class="btn btn-sm btn-default-alt pull-left">Update Image</button>
</div>
</div>
</div>
<div class="form-group">
<label for="user-bio" class="col-lg-2 control-label">Biography</label>
<div class="col-lg-10">
<textarea name="user-bio" id="user-bio" class="form-control" cols="20" rows="3" placeholder="Brief biography"></textarea>
</div>
</div>
<div class="form-group">
<input type="password" class="form-control" name="password" placeholder="Password" required="required">
</div>
<div class="form-group">
<input type="password" class="form-control" name="confirm_password" placeholder="Confirm Password" required="required">
</div>
<div class="form-group">
<button type="submit" class="btn btn-success btn-lg btn-block">Create Account Now</button>
</div>
</form>
</div>
</body>
</html>
see the last few lines and run a snippet to view result

message box to show in right column

I want to design the responsive contact form where the layout is name, email, subject fields be in one column and message field be in the another column. I could not make that message field appear in another column though I have used the width as 50%. Here is the demo
http://jsbin.com/vuxojuqeve/edit?html,css,output
The code
#responsive-form {
max-width: 600px;
margin: 0 auto;
width: 100%;
}
.form-row {
width: 100%;
}
.form-row input {
margin: 10px 0;
}
.clearfix:after {
content: "";
display: table;
clear: both;
}
.button {
float: left;
background: #CA0002;
color: #fff;
text-transform: uppercase;
border: none;
padding: 8px 20px;
cursor: pointer;
}
input[type="text"],
textarea {
width: 100%;
padding: 8px;
border: 1px solid #ccc;
border-radius: 3px;
box-sizing: border-box
}
.half-size {
width: 50%;
}
<div id="responsive-form" class="clearfix">
<div class="half-size">
<div class="form-row">
<div class="column">
<input type="text" name="name" class="form-control">
</div>
</div>
<div class="form-row">
<div class="column">
<input type="text" name="name" class="form-control">
</div>
</div>
<div class="form-row">
<div class="column">
<input type="text" name="name" class="form-control">
</div>
</div>
<div class="form-row">
<div class="column">
<input type="text" name="name" class="form-control">
</div>
</div>
</div>
<div class="half-size">
<div class="form-row">
<div class="column">
<textarea class="form-control" cols="40" rows="10"></textarea>
</div>
</div>
</div>
<div class="form-row">
<div class="column">
<input type="submit" name="name" class="button">
</div>
</div>
</div>
</div>
This is what I wanted with submit button on the left column
You need to set your containers to display:inline-block, as they are block level elements by default and won't allow others to be positioned beside them.
I'm using 45% because 50% + 50% is not usually 100% when using inline-blocks because of an issue with whitespace, there are some ways around it, I'll let you decide for yourself which hack to use...
#responsive-form {
max-width: 600px;
margin: 0 auto;
width: 100%;
}
.form-row {
width: 100%;
}
.form-row input {
margin: 10px 0;
}
.clearfix:after {
content: "";
display: table;
clear: both;
}
.button {
float: left;
background: #CA0002;
color: #fff;
text-transform: uppercase;
border: none;
padding: 8px 20px;
cursor: pointer;
}
input[type="text"],
textarea {
width: 100%;
padding: 8px;
border: 1px solid #ccc;
border-radius: 3px;
box-sizing: border-box
}
.half-size {
width: 45%;
display:inline-block;
}
<div id="responsive-form" class="clearfix">
<div class="half-size">
<div class="form-row">
<div class="column">
<input type="text" name="name" class="form-control">
</div>
</div>
<div class="form-row">
<div class="column">
<input type="text" name="name" class="form-control">
</div>
</div>
<div class="form-row">
<div class="column">
<input type="text" name="name" class="form-control">
</div>
</div>
<div class="form-row">
<div class="column">
<input type="text" name="name" class="form-control">
</div>
</div>
</div>
<div class="half-size">
<div class="form-row">
<div class="column">
<textarea class="form-control" cols="40" rows="10"></textarea>
</div>
</div>
</div>
<div class="form-row">
<div class="column">
<input type="submit" name="name" class="button">
</div>
</div>
</div>
</div>
If there are columns, use flexbox.
Inputs and textarea width unit is vw and e.g. min-width: 180px.
Example
body {
margin: 0;
}
::placeholder,
input[type="submit"] {
color: #BACEE7;
font-weight: bold;
}
.form {
display: flex;
justify-content: center;
padding: 15px;
}
.form input,
.form textarea {
min-width: 180px;
background: #F2F2F2;
border: 1px solid #ccc;
text-transform: uppercase;
border-radius: 3px;
text-align: center;
box-sizing: border-box;
}
.form>.inputs {
margin-right: 5px;
}
.form>.inputs>input {
width: 30vw;
display: block;
margin-bottom: 5px;
padding: 1.5vw;
}
.form>.inputs>input:last-child {
margin-bottom: 0 !important;
}
.form textarea {
width: 35vw;
padding-top: 80px;
display: block;
height: 100%;
}
.form input[type="submit"] {
background: #CA0002;
color: white;
border: none;
cursor: pointer;
}
<div class="form">
<div class="inputs">
<input type="text" name="first_name" placeholder="first name">
<input type="text" name="last_name" placeholder="last name">
<input type="email" name="email" placeholder="email">
<input type="text" name="organization" placeholder="organization">
<input type="tel" name="phone" placeholder="phone">
<input type="submit" name="submit">
</div>
<div class="textarea">
<textarea name="" id="" cols="30" placeholder="message"></textarea>
</div>
</div>

Mailchimp Custom Form CSS

I have created a MailChimp form for the footer of my website, I have modified the CSS with a bit of help to get it looking how it does now. I've become stuck now I attached two images the first one is how I want the form to look and the second one is what the current code makes it look like.
Some help to point me in the right direction would be greatly appreciated.
<div class="row">
<div class="mc-field-group col-lg-6">
<label for="mce-FNAME">First Name:<span class="asterisk"></span></label>
<input type="text" value="" name="FNAME" class="input required" id="mce-FNAME">
</div>
<div class="mc-field-group col-lg-6">
<label for="mce-LNAME">Last Name:<span class="asterisk"></span></label>
<input type="text" value="" name="LNAME" class="input required" id="mce-LNAME">
</div>
</div><!--row-->
<div class="row">
<div class="mc-field-group col-lg-8">
<label class="label" for="mce-EMAIL">Email Address<span class="asterisk"></span></label>
<input type="email" value="" name="EMAIL" class="required input email" id="mce-EMAIL">
</div>
<div class="col-lg-4">
<input type="submit" value="Submit" name="subscribe" id="mc-embedded-subscribe" class="button">
</div>
</div><!--row—>
.mc4wp-form .input {
margin: 10px 0;
float: left;
width: 100%;
line-height: 25px;
border: 1px solid #000;
border-radius: 10px;
}
.mc4wp-form .input:focus,
.mc4wp-form .button:focus {
outline: none;
}
.mc4wp-form .button {
color:#ffffff;
margin-top: 34px;
display: block;
width: 100%;
background: #2451f4;
height: 30px;
font-size: 15px;
border-radius: 10px;
outline: none;
-webkit-transition: all 0.35s ease;
-moz-transition: all 0.35s ease;
-o-transition: all 0.35s ease;
transition: all 0.35s ease;
}
.mc4wp-form .button:hover {
cursor: pointer;
background: #000;
color: #fff;
}
.mc4wp-form {
width: 100%;
max-width: 470px;
}
.mc4wp-form .mc-field-group label {
display: block;
font-size: 22px;
}
.mc4wp-form .row {
display: block;
float: left;
width: 100%;
}
.mc4wp-form .col-lg-6,
.mc4wp-form .col-lg-8,
.mc4wp-form .col-lg-4 {
float: left;
padding: 12px;
box-sizing: border-box;
}
.mc4wp-form .col-lg-6 {
width: 50%;
}
.mc4wp-form .col-lg-8 {
width: 80%;
}
.mc4wp-form .col-lg-4 {
width: 20%;
}
The "Email Address" label has a class of "label" while the other labels do not. Simply delete this class and it will look like the other two.
Find this line:
<label for="mce-EMAIL" class="label">Email Address:</label>
Change it to this:
<label for="mce-EMAIL">Email Address:</label>
Where to find it:
<form action="https://www.kayakinguk.com/" method="post"><div class="mc-field-group col-lg-6">
<label for="mce-FNAME">First Name:</label>
<input type="text" id="mce-FNAME" class="input required" name="FNAME" value="">
</div>
<div class="mc-field-group col-lg-6">
<label for="mce-LNAME">Last Name:</label>
<input type="text" id="mce-LNAME" class="input required" name="LNAME" value="">
</div>
<div class="mc-field-group col-lg-8">
<label for="mce-EMAIL" class="label">Email Address:</label>
<input type="email" id="mce-EMAIL" class="required input email" name="EMAIL" value="">
</div>
The .label class that's changing its background color and font properties is a preset found in bootstrap.css on line 5494 in case you're curious.

Input forms not aligning correctly in Safari

I am currently working on a page Here
I am trying to style the form to be aligned as it is displayed in chrome.
I am sure my way of doing this is out of the park wrong but my styling is working in everything but safari and I cannot figure out why
This is the current code I am using....
<div>
<div>
<br />
<div class="required-notice">
<span class="required-star">*</span><span> = Required Field</span>
</div>
<div class="loan-form-body">
<div>
<span>First Name:</span><span class="required-star">*</span>
</div>
<div>
<input type="text" name="FirstName" id="firstname" class="validate required" style="width: 200px;" />
</div>
<div>
<span>Email Address:</span><span class="required-star">*</span>
</div>
<div>
<input type="text" name="EmailAddress" id="emailaddress" class="validate required" style="width: 200px;" />
</div>
<div>
<span>Address:</span><span class="required-star">*</span>
</div>
<div>
<input type="text" name="HomeAddress" id="HomeAddress" class="validate required" style="width: 430px;" />
</div>
<div>
<div>
<span style="text-align: left; position: absolute; margin-left: 40%; margin-top:-21%;">
Last Name:
<span class="required-star">*</span>
</span>
</div>
<div>
<input type="text" name="LastName" id="lastname" style="width: 200px; position: absolute; margin-left: 40%; margin-top: -18%;" />
</div>
<div style="position: absolute; margin-left: 40%; margin-top: -14%;">
Work Phone:
</div>
<div>
<input type="text" name="DaytimePhone" id="daytimephone" style="width: 200px; position: absolute; margin-left: 40%; margin-top: -10.7%;" />
</div>
</div>
<div class="submit">
<input type="submit" style="width: auto; outline: none; -webkit-appearance: none;" onclick="return validate();" class="button" data-form-type="submit" value="Get An Instant Report" />
</div>
Pardon the messy code.
I fixed your code a little and made some CSS, here's a FIDDLE
<form name="loan-form" class="loan-form" action="#">
<div class="required-notice">
<span class="required-star">*</span>= Required Field
</div>
<div class="loan-form-body">
<label>First Name:<span class="required-star">*</span></label>
<input type="text" name="FirstName" id="firstname" class="validate required" />
<label>Email Address:<span class="required-star">*</span></label>
<input type="text" name="EmailAddress" id="emailaddress" class="validate required" />
<label>Address:<span class="required-star">*</span></label>
<input type="text" name="HomeAddress" id="HomeAddress" class="validate required" />
<label>Last Name:<span class="required-star">*</span></label>
<input type="text" name="LastName" id="lastname" />
<label>Work Phone:</label>
<input type="text" name="DaytimePhone" id="daytimephone" />
<input type="submit" onclick="return validate();" class="button" data-form-type="submit" value="Get An Instant Report" />
</div>
</form>
.loan-form {
width: 400px;
padding: 10px;
font-family: Sans-serif;
font-size: 16px;
border: 1px solid #ddd;
}
.loan-form label {
float: left;
clear: left;
width: 150px;
}
.loan-form input[type="text"] {
float: left;
width: 200px;
margin: 0 0 12px;
padding: 2px 4px;
border: 1px solid #ddd;
outline: none;
transition: box-shadow 0.2s ease-in-out;
-moz-transition: box-shadow 0.2s ease-in-out;
-webkit-transition: box-shadow 0.2s ease-in-out;
}
.loan-form input[type="text"]:focus {
box-shadow: 0 0 3px 0 #333;
-moz-box-shadow: 0 0 3px 0 #333;
-webkit-box-shadow: 0 0 3px 0 #333;
}
.loan-form input[type="submit"] {
display: block;
width: 160px;
height: 26px;
margin: 0 auto;
}
.required-notice {
padding: 7px;
margin: 0 0 15px;
}
.required-star {
vertical-align: top;
margin: 0 3px;
font-size: 12px;
color: red;
}
just finish styling by you wish.

centering div not working

I am trying to center the text and form field inputs in the #registration-code-entry .registration-code-entry-content div
Not sure what I am doing wrong.
http://jsfiddle.net/yLX4F/
<div id="registration-code-entry">
<div class="registration-code-entry-header"></div>
<div class="registration-code-entry-middle">
<div class="registration-code-entry-content">
<form class="registration-form">
<div class="field">
<input type="text" name="first_name" placeholder="*First Name" class="required" />
</div>
<div class="field">
<input type="text" name="last_name" placeholder="*Last Name" class="required" />
</div>
<div class="field">
<input type="email" name="email" placeholder="*Email Address" class="required" />
</div>
<div class="field">
<input type="text" name="phone" placeholder="Phone Number" />
</div>
<div class="field">
<input type="checkbox" name="optin">
<label for="optin" />Yes, I would like to receive more information</label>
</div>
<div class="field">
<input type="checkbox" name="accept" class="required" />
<label for="accept">*I accept the Official Rules.</label>
</div>
<input type="submit" class="submit-btn" value="">
</form>
</div>
</div>
<div class="registration-code-entry-footer"></div>
</div>
css
#registration-code-entry {
height: 100px;
width: 359px;
position: absolute;
top: 100px;
right: 20px;
background: transparent;
.registration-code-entry-header {
top: 0;
background: transparent url('../images/form-header.png') no-repeat;
width: 359px;
height: 17px;
}
.registration-code-entry-middle {
background: #713487;
.registration-code-entry-content {
border: 1px solid red;
width: 350px;
margin: 0 auto;
color: #fff;
form {
display: inline-block;
margin: 0 auto;
.field {
margin: 10px 0;
input[type="email"], input[type="text"] {
padding: 5px;
}
}
input.submit-btn {
background: transparent url('../images/submit-btn.png') no-repeat;
width: 168px;
height: 59px;
display: block;
border: 0;
}
}
}
}
.registration-code-entry-footer {
display: block;
bottom: 0;
background: transparent url('../images/form-footer.png') no-repeat;
width: 359px;
height: 11px;
}
}
You can add text-align: centerto .field. You can also change to display: block for form to make the form expand to the full width of the parent.
jsfiddle
Centering the input ?
This will centering it :
.field input[type="text"], .field input[type="email"] {
display:block;
margin: auto;
}
Check This
Just change youre less :
...
.field {
margin: 10px 0;
input[type="email"], input[type="text"] {
padding: 5px;
display:block;
margin:0 auto;
}
}
...