how can I align the labels & inputs to the right - html

how can I align the labels & inputs to the right
like that all of then appear in the same line
.radioContainer{
width: fit-content;
margin: 5px;
margin-top: 20px;
background-color: aqua;
padding-bottom: 25px;
}
<div class="radioContainer" style="margin-bottom: 40px; margin-right: 0px; ">
<label class="title" for="">fav food</label>
<label for="burger">burger</label>
<input type="checkbox" id="burger">
<br>
<label for="fries">fries</label>
<input type="checkbox" id="fries">
<br>
<label for="onionRings">onion rings</label>
<input type="checkbox" id="onionRings">
<br>
<label for="cackes">cakes</label>
<input type="checkbox" id="cackes" >
<small></small>
</div>

To have them in the same line, I would start by removing <br /> from your code. Then set the css for input and label to be inline-block, something like:
.radioContainer{
width: fit-content;
margin: 5px;
margin-top: 20px;
background-color: aqua;
padding-bottom: 25px;
}
label, input { display: inline-block; }
<div class="radioContainer" style="margin-bottom: 40px; margin-right: 0px; ">
<label class="title" for="">fav food</label>
<label for="burger">burger</label>
<input type="checkbox" id="burger">
<label for="fries">fries</label>
<input type="checkbox" id="fries">
<label for="onionRings">onion rings</label>
<input type="checkbox" id="onionRings">
<label for="cackes">cakes</label>
<input type="checkbox" id="cackes" >
<small></small>
</div>

To make all inputs inline, just remove all the <br /> tags.
Example:
<div class="radioContainer" style="margin-bottom: 40px; margin-right: 0px; ">
<label class="title" for="">fav food</label>
<label for="burger">burger</label>
<input type="checkbox" id="burger">
<label for="fries">fries</label>
<input type="checkbox" id="fries">
<label for="onionRings">onion rings</label>
<input type="checkbox" id="onionRings">
<label for="cackes">cakes</label>
<input type="checkbox" id="cackes">
<small></small>
</div>
Codepen: https://codepen.io/manaskhandelwal1/pen/jOMeqex

I understood your Question that you want them still below each other but aligned to the right side. So i made a solution using flexbox instead of the hard breaks. I commented the Code where i made changes and why, html and css.
Basically i used a colum and put each item-combination (label and checkbox)in a new row-div.
.radioContainer{
width: fit-content;
margin: 5px;
margin-top: 20px;
background-color: aqua;
padding-bottom: 25px;
/*make item a flexbox-container*/
display: flex;
/*combination of flex-direction and flex-wrap*/
flex-flow: column wrap;
}
.row{
/*make item a flexboc container*/
display: flex;
/*flex-flow: row nowrap; this is the default value of flex, which is why you dont need it,
just wanted to leave it in as a comment so you know whats happening*/
/*Align the contents on the end of each row*/
justify-content: flex-end;
}
<div class="radioContainer" style="margin-bottom: 40px; margin-right: 0px; ">
<!--removed the hard breaks and added row-divs around each item combination-->
<div class="row">
<label class="title" for="">fav food</label>
</div>
<div class="row">
<label for="burger">burger</label>
<input type="checkbox" id="burger">
</div>
<div class="row">
<label for="fries">fries</label>
<input type="checkbox" id="fries">
</div>
<div class="row">
<label for="onionRings">onion rings</label>
<input type="checkbox" id="onionRings">
</div>
<div class="row">
<label for="cackes">cakes</label>
<input type="checkbox" id="cackes" >
</div>
<small></small>
</div>

Related

Left align title with input boxes flexbox

I was wondering whether there is a better way (more dynamic) way of left aligning the title with the input boxes below it using flexbox. The input boxes need to be displayed inline with the title above them. Currently I've had to wrap a div around both the title and input boxes and set a fixed pixel width. Is there a better way of achieving the same result with flexbox?
I've tried using inline-flex on this wrapper but it's still treating it as a full width element instead of being as wide as its content. I've also tried setting inline-flex on the unordered list and the result is exactly the same.
I would like to not have to set a fixed pixel width. The next time if I need to do the same but with a different element, I would need to keep setting a fixed pixel size which isn't ideal.
Thanks in advance
html {
font-size: 14px;
}
.section {
padding: 1.5rem;
}
.wrapper {
display: flex;
background: lightblue;
}
.warning-percentage-wrapper {
background: lightcoral;
flex: 0 0 30%;
}
.warning-percentage {
display: inline-flex;
margin-left: -1rem;
}
.warning-percentage li {
flex: 0 1 80px;
margin-left: 1rem;
}
.days-of-week-wrapper {
background: lightseagreen;
flex: 1;
display: flex;
justify-content: flex-end;
}
.inline-wrapper {
background: pink;
display: flex;
flex-direction: column;
flex: 0 1 644px;
}
.days-of-week {
display: inline-flex;
margin-left: -1rem;
}
.days-of-week li {
flex: 0 1 80px;
margin-left: 1rem;
}
<section class="section">
<div class="wrapper">
<div class="warning-percentage-wrapper">
<h5 class="title is-5">Warning Percentages</h5>
<ul class="warning-percentage">
<li>
<label class="label">Low</label>
<input class="input" type="text" readonly>
</li>
<li>
<label class="label">Medium</label>
<input class="input" type="text" readonly>
</li>
<li>
<label class="label">High</label>
<input class="input" type="text" readonly>
</li>
</ul>
</div>
<div class="days-of-week-wrapper">
<div class="inline-wrapper">
<h5 class="title is-5">Days of Week</h5>
<ul class="days-of-week">
<li>
<label class="label">Monday</label>
<input class="input" type="text" readonly>
</li>
<li>
<label class="label">Tuesday</label>
<input class="input" type="text" readonly>
</li>
<li>
<label class="label">Wednesday</label>
<input class="input" type="text" readonly>
</li>
<li>
<label class="label">Thursday</label>
<input class="input" type="text" readonly>
</li>
<li>
<label class="label">Friday</label>
<input class="input" type="text" readonly>
</li>
<li>
<label class="label">Saturday</label>
<input class="input" type="text" readonly>
</li>
<li>
<label class="label">Sunday</label>
<input class="input" type="text" readonly>
</li>
</ul>
</div>
</div>
</div>
</section>
if you want something as same as the pic you put in your question, you must remove padding/margin from your elements (such as input, label)
html {
font-size: 14px;
}
.wrapper {
display: flex;
background: lightblue;
}
.warning-percentage-wrapper {
background: lightcoral;
}
.warning-percentage {
display: inline-flex;
}
.warning-percentage li {
flex: 0 1 80px;
margin-left: 1rem;
}
.days-of-week-wrapper {
background: lightseagreen;
flex: 1;
display: flex;
justify-content: flex-end;
}
.inline-wrapper {
background: pink;
display: flex;
flex-direction: column;
}
.days-of-week {
display: inline-flex;
}
<section class="section">
<div class="wrapper">
<div class="warning-percentage-wrapper">
<h5 class="title is-5">Warning Percentages</h5>
<ul class="warning-percentage">
<li>
<label class="label">Low</label>
<input class="input" type="text" readonly>
</li>
<li>
<label class="label">Medium</label>
<input class="input" type="text" readonly>
</li>
<li>
<label class="label">High</label>
<input class="input" type="text" readonly>
</li>
</ul>
</div>
<div class="days-of-week-wrapper">
<div class="inline-wrapper">
<h5 class="title is-5">Days of Week</h5>
<ul class="days-of-week">
<li>
<label class="label">Monday</label>
<input class="input" type="text" readonly>
</li>
<li>
<label class="label">Tuesday</label>
<input class="input" type="text" readonly>
</li>
<li>
<label class="label">Wednesday</label>
<input class="input" type="text" readonly>
</li>
<li>
<label class="label">Thursday</label>
<input class="input" type="text" readonly>
</li>
<li>
<label class="label">Friday</label>
<input class="input" type="text" readonly>
</li>
<li>
<label class="label">Saturday</label>
<input class="input" type="text" readonly>
</li>
<li>
<label class="label">Sunday</label>
<input class="input" type="text" readonly>
</li>
</ul>
</div>
</div>
</div>
</section>
<!-- end snippet -->
The problem I'm having with inline-flex is caused using a flex basis with a pixel value. I needed the inputs to all be the same width. I forgot to mention I am using Bulma (not by choice) which removes all the margins and padding's from elements by default.
My example below should hopefully provide a better understanding of the problem. Notice I've set the UL - 'days-of-week' to align-self. Now the UL is as wide a its content which is what I wanted. However if you hover over the element with your dev tools there's still quite a bit of space remaining. This is because I'm using a flex-basis with a pixel value. If you set to LI to flex: 1 and inspect the DOM, the elements are nicely fill the space, including the margins.
The solution for this is to remove the flex styles altogether on the LI elements and set a fixed pixel width on the 'inline-wrapper' element. I don't think this is ideal but it allows you to control the size of the LI's without needing additional css styling on the LI's themselves.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
<link href="bulma-0.8.0/css/bulma.min.css" rel="stylesheet" />
<style>
html {
font-size: 14px;
}
.section {
padding: 1.5rem;
}
.wrapper {
display: flex;
background: lightblue;
}
.warning-percentage-wrapper {
background: lightcoral;
flex: 0 0 30%;
}
.warning-percentage {
display: inline-flex;
margin-left: -1rem;
}
.warning-percentage li {
flex: 0 1 80px;
margin-left: 1rem;
}
.days-of-week-wrapper {
background: lightseagreen;
flex: 1;
display: flex;
justify-content: flex-end;
}
.inline-wrapper {
background: pink;
display: flex;
flex-direction: column;
flex: 0 1 644px;
}
.days-of-week {
display: inline-flex;
align-self: flex-start;
}
.days-of-week li {
flex: 0 1 80px;
margin-left: 1rem;
}
.days-of-week li:first-child {
margin-left: 0;
}
</style>
</head>
<body>
<section class="section">
<div class="wrapper">
<div class="warning-percentage-wrapper">
<h5 class="title is-5">Warning Percentages</h5>
<ul class="warning-percentage">
<li>
<label class="label">Low</label>
<input class="input" type="text" readonly>
</li>
<li>
<label class="label">Medium</label>
<input class="input" type="text" readonly>
</li>
<li>
<label class="label">High</label>
<input class="input" type="text" readonly>
</li>
</ul>
</div>
<div class="days-of-week-wrapper">
<div class="inline-wrapper">
<h5 class="title is-5">Days of Week</h5>
<ul class="days-of-week">
<li>
<label class="label">Monday</label>
<input class="input" type="text" readonly>
</li>
<li>
<label class="label">Tuesday</label>
<input class="input" type="text" readonly>
</li>
<li>
<label class="label">Wednesday</label>
<input class="input" type="text" readonly>
</li>
</ul>
</div>
</div>
</div>
</section>
</body>
</html>

Space between two row classes in HTML (Angular)

I have 3 rows with 2 columns in each row on my HTML page with some labels and inputs.
I see a lot of space between the rows which I tried removing but didn't work. Is there a way to do it?
Here's the HTML Code :
<div >
<h1>
New Patient Record
</h1>
</div>
<div class="row" style="padding-bottom: 0px;">
<div class="column"></div>
<div class="column">
<label > <strong>Date</strong> </label>
<input type="date" name="date" id="date" class="form-control" [(ngModel)]="institutes.date">
</div>
</div>
<div class="row" style="padding-top:0px" >
<div class="container" style="padding-left: 7.5%" >
<form #institutesForm="ngForm" (ngSubmit)="instituteLogins(institutesForm)">
<div class="form-group">
<div class="row">
<div class="column">
<h2><strong> Symptoms</strong> </h2>
<input type="text" name="symtoms" id="symtoms" class="form-control"[(ngModel)]="institutes.symtoms">
<br>
<h2><strong>Diagnosis</strong></h2>
<label> <strong>Condition</strong> </label>
<input type="text" name="condition" id="condition" class="form-control"[(ngModel)]="institutes.condition">
<label><strong> Advice </strong></label>
<input type="text" name="advice" id="advice" class="form-control"[(ngModel)]="institutes.advice">
<br>
</div>
<div class="column">
<h2> <strong>Prescription</strong> </h2>
<br>
<label><strong> Medication </strong></label>
<input type="text" name="medication" id="medication" class="form-control"[(ngModel)]="institutes.medication">
<label><strong> Medicine Type </strong></label>
<input type="text" name="type" id="type" class="form-control"[(ngModel)]="institutes.type">
<label><strong>Course</strong></label>
<input type="text" id="course" name="course" class="form-control"[(ngModel)]="institutes.course">
<label><strong> How many per day? </strong></label>
<input type="text" name="cday" id="cday" class="form-control"[(ngModel)]="institutes.cday">
<br>
</div>
<div class="row">
<div class="column"></div>
<div class="column">
<button id="record" class="btn btn-primary" type="submit" >Add Record</button>
</div>
</div>
</div>
<br><br>
</div>
</form>
</div>
Here's what all I tried: I tried to adjust row spacing using margins, and padding but none of them worked. Is there any other alternative for this?
.modal-dialog.cascading-modal.modal-avatar .modal-header img {
width: 130px;
margin-left: auto;
margin-right: auto;
}
.modal-dialog.cascading-modal.modal-avatar .modal-header {
margin: -6rem 2rem -1rem 2rem;
}
.More{
color: blue;
margin-right: 100px;
}
.column{
margin : 100px;
}
.row{
margin:0;
padding:0;
align-items: baseline;
}
Changing:
.column{
margin: 100px;
}
To
.column{
margin-left : 100px;
margin-right: 100px;
}
Will remove the space between the rows. Is that the end result you're looking for?
Adjusting the margin-left helped me solve the issue.
Also using to add number of empty spaces vertically solved my UI design issues.
For the space between both rows, you can add the padding-bottom
style="margin-top:-50px"

Aligning form input elements of varying lengths

I need to create a form using only HTML and CSS. The form fields are of different lengths depending on which field it is.
I've tried just about every solution I've found on SO and other sites that use things like display modes but those all seem to be aimed at forms where all the input fields are the same size. I've also tried to use a table to make the form but I don't know enough about them to make that work. I am still open to using a table if anyone is willing to teach me how to have it work.
form {
margin-top: 25px;
}
.form {
margin-left: 10px;
background-color: #fff;
float: left;
width: 620px;
}
.form p {
margin-left: 10px;
}
.form h3,
.summary h3 {
font-size: 36px;
background-color: #fff;
width: auto;
padding-top: 35px;
}
.form label {
font-family: Arial, sans-serif;
font-size: 14px;
display: block;
margin-left: 10px;
color: #8f8f8f;
}
input {
float: left;
margin-left: 10px;
background-color: #f9f9f9;
border: 1px solid #cdcdcd;
height: 36px;
border-radius: 2px;
}
.form span {
color: #861919;
}
.name {
width: 288px;
}
.bigbar {
width: 448px;
}
.smallbar {
width: 128px;
}
<form action="#" method="POST">
<label for="firstname">First Name <span>*</span></label>
<input type="text" id="firstname" required class="name" />
<label for="lastname">Last Name <span>*</span></label>
<input type="text" id="lastname" required class="name" />
<label for="address">Street Address <span>*</span></label>
<input type="text" id="address" required class="bigbar" />
<label for="apt">Apt/Unit/Suite #</label>
<input type="text" id="apt" class="smallbar" />
<label for="city">City <span>*</span></label>
<input type="text" id="city" required class="bigbar" />
<label for="province">Province <span>*</span></label>
<input type="text" id="province" required class="smallbar" />
<label for="code">Postal Code <span>*</span></label>
<input type="text" id="code" required class="smallbar" />
<label for="phone">Phone Number <span>*</span></label>
<input type="tel" id="phone" required class="bigbar" />
<button type="submit" id="submit">Continue Checkout</button>
</form>
At the end it's supposed to look like this: https://puu.sh/DQhyH/2aed3ce204.png
but as far as I'm able to get it with my knowledge it looks like this: https://puu.sh/DQhAs/eb0a1eeb5b.png (can't post images due to just making my account)
so it's almost there but the fields aren't aligned properly.
This could be done fairly easy with a table using colspan attribute on td elements. However, tables are intended for the display of data, and should be not used for layout (this article lists several reasons why).
You need to look at your desired result and form a grid with containing div elements. You have several "rows", so put the content of each row inside a div.row that takes the full width. Your content within the rows is either 1,2, or 3 "columns" wide out of 4 total. So you make div.col1, div.col2, div.col3 with appropriate widths and inline-block display. Then just make sure you put four columns in each row. The containing divs now determine the widths so we set inputs and labels to width:100% to take the full width of their respective parents.
div.field {
display: inline-block;
padding: .5em;
}
div.row,
input,
label,
button {
width: 100%;
}
form {
margin-top: 25px;
width: 620px;
}
form label {
font-family: Arial, sans-serif;
font-size: 14px;
display: block;
margin-left: 10px;
color: #8f8f8f;
}
input {
/*float: left;*/
margin-left: 10px;
background-color: #f9f9f9;
border: 1px solid #cdcdcd;
height: 36px;
border-radius: 2px;
}
form span {
color: #861919;
}
.col2 {
width: 288px;
}
.col3 {
width: 448px;
}
.col1 {
width: 128px;
}
<form action="#" method="POST">
<div class="row">
<div class="col2 field">
<label for="firstname">First Name <span>*</span></label>
<input type="text" id="firstname" required/>
</div>
<div class="col2 field">
<label for="lastname">Last Name <span>*</span></label>
<input type="text" id="lastname" required/>
</div>
</div>
<div class="row">
<div class="col3 field">
<label for="address">Street Address <span>*</span></label>
<input type="text" id="address" required class="bigbar" />
</div>
<div class="col1 field">
<label for="apt">Apt/Unit/Suite #</label>
<input type="text" id="apt" />
</div>
</div>
<div class="row">
<div class="col3 field">
<label for="city">City <span>*</span></label>
<input type="text" id="city" required/>
</div>
<div class="col1 field">
<label for="province">Province <span>*</span></label>
<input type="text" id="province" required/>
</div>
</div>
<div class="row">
<div class="col1 field">
<label for="code">Postal Code <span>*</span></label>
<input type="text" id="code" required/>
</div>
<div class="col3 field">
<label for="phone">Phone Number <span>*</span></label>
<input type="tel" id="phone" required/>
</div>
</div>
<div class="row">
<div class="col1 field"></div>
<div class="col2 field">
<button type="submit" id="submit">Continue Checkout</button>
</div>
<div class="col1 field"></div>
</div>
</form>

center form on the page

I am trying to get my form to center on desktop. It's currently to the left side.
I tried doing display: block and margin-left: auto and margin-right: auto and it is still being fussy.
The picture below shows the issue and I'll add a snippet and a fiddle to help. Thanks in advance.
Jsfiddle: https://jsfiddle.net/r87h2L6n/
/*********FORMS CSS*************/
form {
display: block;
margin-left: auto;
margin-right: auto;
}
form.contact label {
display: block;
}
span {
display: block;
border: none;
color: white;
}
.clearfix:after {
content: " ";
display: block;
clear: both;
}
fieldset {
width: 45%;
float: left;
border: none;
}
input.checks {
width: auto;
}
.left {
width: 45%;
float: left;
}
.right {
width: 45%;
float: right;
}
input {
border: none;
border-bottom: 2px solid #959595;
width: 300px;
margin: 3px;
color: #6C6A6A;
padding-top: 10px;
padding-bottom: 10px;
}
.bottom {
border: none;
margin: 3px;
color: #6C6A6A;
padding-top: 10px;
padding-bottom: 10px;
width: 300px;
}
.fa {
margin-right: 10px;
}
legend {
color: white;
}
.button {
display: inline-block;
padding: 15px 25px;
font-size: 14px;
cursor: pointer;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #595959;
border: none;
border-radius: 15px;
box-shadow: 0 9px #999;
width: 150px;
}
.button:hover {
background-color: #670809
}
.button:active {
background-color: #670809;
box-shadow: 0 5px #666;
transform: translateY(4px);
}
<section class="clearfix" id="fourthpara">
<div class="imgbox5">
<img id="pic5" class="adjustable float move" src="http://weknowyourdreams.com/images/kitten/kitten-08.jpg" alt="example web page">
</div>
<h2>Student Review 3</h2>
<p class="side">
“This class is up to date on the latest techniques, the instructor is willing to go the extra mile, and the class is well structured” -Papa Smurf
</p>
</section>
</div>
</section>
<div class="center clearfix">
<h1 id="fourth">Contact</h1>
<form action="FormToEmail.php" method="POST" enctype="multipart/form-data" autocomplete="on" class="contact clearfix ">
<section class="clearfix">
<fieldset>
<legend>
<i class="fa fa-user" aria-hidden="true"></i>Personal Information
<hr class="style2">
</legend>
<label><span></span>
<input name="first_name" type="text" value="" placeholder="First Name" required/>
</label>
<label><span>
</span>
<input name="last_name" type="text" value="" placeholder="Last Name" required/>
</label>
<label><span> </span>
<input name="date_of_birth" type="date" value="" placeholder="Date of Birth" required/>
</label>
<label><span>
</span>
<input type="number" name="quantity" min="1" max="6" placeholder="number of years until next degree">
</label>
<label><span></span>
<input name="level_of_education" type="hidden" value="" placeholder="level of education" required/>
</label>
<select class="bottom" name="education_level">
<option value="High School">High School</option>
<option value="Undergraduate">Undergradute</option>
<option value="Graduate">Graduate</option>
</select>
</fieldset>
<fieldset>
<legend><i class="fa fa-envelope-o" aria-hidden="true"></i>
Contact Information
<hr class="style2">
</legend>
<label><span>
</span>
<input class="ghost-input" name="email" value="" type="email" placeholder="youremail#email.com" autocomplete="off" />
</label>
<label><span></span>
<input name="phonenumber" value="" type="tel" placeholder="763-858-9564" />
</label>
<label><span></span>
<input name="website" value="" type="url" placeholder="https://yourwebsite.com" />
</label>
</fieldset>
</section>
<section class="clearfix column">
<fieldset>
<legend><i class="fa fa-laptop" aria-hidden="true"></i>
What are your Interests
<hr class="style2">
</legend>
<section class="clearfix column left">
<label class="bottom span"><span><input name="webdesign" value="web_design" type="checkbox" class="checks"/>Web Design</span>
</label>
<label class="bottom"><span><input name="webdevelopment" value="web_development" type="checkbox" class="checks" />Web Development</span>
</label>
<label class="bottom"><span><input name="computerscience" value="computer_science" type="checkbox"class="checks" />Computer Science</span>
</label>
</section>
<section class="clearfix column left">
<label class="bottom"><span><input name="graphicdesign" value="graphic_design" type="checkbox" class="checks"/>Graphic Design</span>
</label>
<label class="bottom"><span><input name="userexperience" value="user_experience" type="checkbox" class="checks" />User Experience</span>
</label>
<label class="bottom"><span><input class="checks" name="appdevelopment" value="app_development" type="checkbox" />App Development</span>
</label>
</section>
</fieldset>
<fieldset>
<legend><i class="fa fa-volume-control-phone" aria-hidden="true">
</i>
Follow Up
<hr class="style2 toosmall">
</legend>
<section class="clearfix column left">
<legend class="smaller">You can contact me by:</legend>
<br>
<div class="squish">
<label class="bottom"><span><input class="checks" name="contact_me" type="radio" value="phone" checked/>Contact me by phone</span>
</label>
<label class="bottom"><span><input class="checks" name="contact_me" type="radio" value="email" checked/>Contact me by email</span>
</label>
<label class="bottom"><span><input class="checks" name="contact_me" type="radio" value="text"/>Contact me by text</span>
</label>
<br>
</div>
</section>
<section class="clearfix column left">
<legend class="smaller">I'm interested in:</legend>
<br>
<label class="bottom"><span><input class="checks" name="interest" type="radio" value="text"/>Undergraduate</span>
</label>
<label class="bottom"><span><input class="checks" name="interest" type="radio" value="text"/>Graduate</span>
</label>
<label class="bottom"><span><input class="checks" name="interest" type="radio" value="text"/>Online</span>
</label>
</section>
</fieldset>
</section>
<input class="button" name="submit_to_programmer" type="submit" value="Submit" />
<input type="hidden" value="Message from Car Website" name="subject">
<input name="redirect" type="hidden" value="thanks.html">
</form>
To add to Michael_B`s answer your form is set to take up the full width of the page as its a block element by default and you have set it as well. Margin auto only works for elements that are block or inline-block elements and they width of either must be set to a specified value for it to work.
To address your problem now, looking at your source code, you can get the result you expect by removing the float set on your fieldset element in your CSS and setting Margin to auto in that element. I am not sure what the purpose of the float in that CSS rule but you cannot center something that you have set to float. Hope this helps
The reason it's not centering is that your form element is a block level container and, therefore, it's occupying 100% width of the page. As a result, there no space left for centering.
As you wrote:
I tried doing display: block and margin-left: auto and margin-right: auto and it is still being fussy.
Well, if you give an element display: block it consumes all available horizontal space. Hence, margin-left: auto and margin-right: auto have no effect.
Try defining a width for the form (e.g. width: 30em), removing float rules and/or giving the form text-align: center, which centers the child elements.
It's not your form that is the issue here, it is your fieldset...again. Give this a whirl.
fieldset {
width: 45%;
margin: 0 auto;
/* float: left; -- DELETE float: left if you want this centered */
border: none;
}
UPDATE:
If you also want that submit button to be centered, here is the css for that.
.button {
margin: 0 auto; /* ADDED THIS */
display: block; /* Took inline-block out, just use block */
padding: 15px 25px;
font-size: 14px;
cursor: pointer;
text-align: center;
text-decoration: none;
outline: none;
color: #fff;
background-color: #595959;
border: none;
border-radius: 15px;
box-shadow: 0 9px #999;
width: 150px;
}
LIVE DEMO

Css Align Div next to another Div

Can someone please help me with this css? I am very new and for some reason cannot figure something out that seems to be extremely simple. What I am trying to do is have gvw_field align next to the ew_field. I am not sure how to align the <div> 's next to each other.
http://jsfiddle.net/r45xfbex/
#gvw_field {
text-align:center;
}
<div class="clearfix">
<div id="ew_field">
<label for="ew">Empty Weight:</label>
<input type="text" name="ew" id="ew" value="">
</div>
<div id="gvw_field">
<label for="gvw" >Gross Vehicle Weight:*</label>
<input type="text" name="gvw" id="gvw" value="">
</div>
<div id="ft_field">
<label for="ft">Feet:</label>
<input type="text" name="ft" id="ft" value="">
</div>
</div>
Working jsFiddle Demo
The display: inline property will do it.
#gvw_field, #ew_field{
display: inline;
}
Readup about display property on MDN.
Working code snippet:
#gvw_field {
text-align:center;
}
#gvw_field, #ew_field{
display: inline;
}
<div class="clearfix">
<div id="ew_field">
<label for="ew">Empty Weight:</label>
<input type="text" name="ew" id="ew" value="">
</div>
<div id="gvw_field">
<label for="gvw" >Gross Vehicle Weight:*</label>
<input type="text" name="gvw" id="gvw" value="">
</div>
<div id="ft_field">
<label for="ft">Feet:</label>
<input type="text" name="ft" id="ft" value="">
</div>
</div>
Use floats to align each <div>
#gvw_field {
text-align:center;
}
.column{
width: 33.33%;
float: left;
}
<div class="clearfix">
<div class="column" id="ew_field">
<label for="ew">Empty Weight:</label>
<input type="text" name="ew" id="ew" value="">
</div>
<div class="column" id="gvw_field">
<label for="gvw" >Gross Vehicle Weight:*</label>
<input type="text" name="gvw" id="gvw" value="">
</div>
<div class="column" id="ft_field">
<label for="ft">Feet:</label>
<input type="text" name="ft" id="ft" value="">
</div>
</div>
use float and don't use same id for many items:
CSS:
.ft_field
{
float: right;
width: 50%;
}
label {
display: inline-block;
width: 170px;
}
.gvw_field {
float: right;
width: 50%;
}
HTML:
<div class="clearfix">
<div class="ew_field">
<label for="ew">Empty Weight:</label>
<input type="text" name="ew" id="ew" value=""/>
</div>
<div class="gvw_field">
<label for="gvw" >Gross Vehicle Weight:*</label>
<input type="text" name="gvw" id="gvw" value=""/>
</div>
<div class="ft_field">
<label for="ft">Feet:</label>
<input type="text" name="ft" id="ft" value=""/>
</div>
</div>
jsfiddle
You you need a display value of inline and also a given width.
#ew_field, #ft_field, #gvw_field {
text-align: center;
display: inline-block;
width: 150px; /* Adjust as needed */
}
See working demo here