I am creating a credit card form in HTML and CSS. Everything is good so far, except the top portion where I display what is in the "Cart". I created a table so that the info can be evenly displayed. However, if you run the snippet, you can see that the table headers and data are not evenly spaced out. Can someone tell me what I am doing wrong? I tried using margin-left in the and class, but it does not work, it won't even shift to the left.
body {
font-family: Arial;
font-size: 17px;
padding: 8px;
}
* {
box-sizing: border-box;
}
.row {
display: -ms-flexbox; /* IE10 */
display: flex;
-ms-flex-wrap: wrap; /* IE10 */
flex-wrap: wrap;
margin: 0 -16px;
}
.col-25 {
-ms-flex: 25%; /* IE10 */
flex: 25%;
}
.col-50 {
-ms-flex: 50%; /* IE10 */
flex: 50%;
}
.col-75 {
-ms-flex: 75%; /* IE10 */
flex: 75%;
}
.col-25,
.col-50,
.col-75 {
padding: 0 16px;
}
.container {
background-color: #f2f2f2;
padding: 5px 20px 15px 20px;
border: 1px solid lightgrey;
border-radius: 3px;
}
input[type=text] {
width: 100%;
margin-bottom: 20px;
padding: 12px;
border: 1px solid #ccc;
border-radius: 3px;
}
label {
margin-bottom: 10px;
display: block;
}
.icon-container {
margin-bottom: 20px;
padding: 7px 0;
font-size: 24px;
}
.btn {
background-color: #4CAF50;
color: white;
padding: 12px;
margin: 10px 0;
border: none;
width: 100%;
border-radius: 3px;
cursor: pointer;
font-size: 17px;
}
.btn:hover {
background-color: #45a049;
}
a {
color: #2196F3;
}
hr {
border: 1px solid lightgrey;
}
span.price {
float: right;
color: grey;
}
<div class="row">
<div class="col-25">
<div class="container">
<h4>Cart</h4>
<table>
<tr>
<th>Company</th>
<th >Plan</th>
<th>Packages</th>
<th>Price/pckg</th>
<th>total</th>
</tr>
<tr>
<td>Joes Pizza</td>
<td>Premium</td>
<td>10,000</td>
<td>$0.039</td>
<td>390.00</td>
</tr>
</table>
<hr>
<p>Total <span class="price" style="color:black"><b>$390.00</b></span></p>
</div>
</div>
<div class="col-75">
<div class="container">
<form>
<div class="row">
<div class="col-50">
<h3>Billing Information</h3>
<label for="fname"><i class="fa fa-user"></i> Company Name</label>
<input type="text" id="fname" name="firstname">
<label for="email"><i class="fa fa-envelope"></i> Email</label>
<input type="text" id="email" name="email">
<label for="adr"><i class="fa fa-address-card-o"></i> Address</label>
<input type="text" id="adr" name="address">
<label for="city"><i class="fa fa-institution"></i> City</label>
<input type="text" id="city" name="city">
<div class="row">
<div class="col-50">
<label for="state">State</label>
<input type="text" id="state" name="state">
</div>
<div class="col-50">
<label for="zip">Zip</label>
<input type="text" id="zip" name="zip">
</div>
</div>
</div>
<div class="col-50">
<h3>Payment</h3>
<label for="fname">Accepted Cards</label>
<div class="icon-container">
<i class="fa fa-cc-visa" style="color:navy;"></i>
<i class="fa fa-cc-amex" style="color:blue;"></i>
<i class="fa fa-cc-mastercard" style="color:red;"></i>
<i class="fa fa-cc-discover" style="color:orange;"></i>
</div>
<label for="cname">Name on Card</label>
<input type="text" id="cname" name="cardname">
<label for="ccnum">Credit card number</label>
<input type="text" id="ccnum" name="cardnumber">
<label for="expmonth">Exp Month</label>
<input type="text" id="expmonth" name="expmonth">
<div class="row">
<div class="col-50">
<label for="expyear">Exp Year</label>
<input type="text" id="expyear" name="expyear">
</div>
<div class="col-50">
<label for="cvv">CVV</label>
<input type="text" id="cvv" name="cvv">
</div>
</div>
</div>
</div>
<div class="row">
<div class="col-50">
<label for="ccnum">Bank Account</label>
<input type="text" id="ccnum" name="cardnumber">
</div>
<div class="col-50">
<label for="ccnum">Routing Number</label>
<input type="text" id="ccnum" name="cardnumber">
</div>
</div>
<input type="submit" value="Submit payment" class="btn">
</form>
</div>
</div>
</div>
The tables headers and the table data in your code are equally spaced but they do not look so because they are center-aligned. I have aligned td and th to left and gave padding for a better appearance and also gave the same widths to each th (no need to set widths in td if set in th).
Thanks
table tr th,
table tr td {
text-align: left;
padding: 2px 2px;
border: 1px solid black;
}
<div class="row">
<div class="col-25">
<div class="container">
<h4>Cart</h4>
<table>
<tr>
<th width="20%">Company</th>
<th width="20%">Plan</th>
<th width="20%">Packages</th>
<th width="20%">Price/pckg</th>
<th>total</th>
</tr>
<tr>
<td>Joes Pizza</td>
<td>Premium</td>
<td>10,000</td>
<td>$0.039</td>
<td>390.00</td>
</tr>
</table>
<hr>
<p>Total <span class="price" style="color:black"><b>$390.00</b></span></p>
</div>
</div>
Related
I have a problem with your form, how can I put the text and the elements at the same distance, e.g. show the label next to the fields, they are not on the same line, i.e. not centered on the line,
pls see pic on the Link
My Form
I have a problem with your form, how can I put the text and the elements at the same distance, e.g. show the label next to the fields, they are not on the same line, i.e. not centered on the line,
pls see pic on the Link
My Form
I have a problem with your form, how can I put the text and the elements at the same distance, e.g. show the label next to the fields, they are not on the same line, i.e. not centered on the line,
pls see pic on the Link
My Form
body{
padding: 0;
margin: 0;
box-sizing: border-box;
font-family: 'Poppins', sans-serif;
background-color: #FFBB00;
}
.container{
width: 40%;
margin: 4% auto;
padding: 50px;
background-color: #fff;
border-radius: 15px;
box-shadow: #ccc 0 0 10px 0; /* للظل لحتى يطلع متناسب */
}
.title h1{
position: relative;
text-align: center;
font-size: 28px;
text-transform: uppercase;
}
.title h1::after{
content: "";
width: 30%;
height: 3px;
background-color: #FFBB00;
position: absolute;
top: 110%;
left: 35%;
}
.inputFeld{
padding: 10px;
margin: 10px;
border-radius:4px;
border: 1px solid #ccc;
}
.inputFeld:focus{
background-color: #FFBB00; ;
}
/* */
.parent-line{
display: flex;
flex-wrap: wrap;
justify-content: center;
align-content: center;
padding: 15px;
}
.parent-line .line-link{
display: flex;
flex: 1;
}
.parent-line .line-right{
flex: 1;
display: flex;
}
.parent-one-line{
padding: 15px;
}
.container .line label{
display: inline-block;
width: 150px;
text-align: left;
}
/* */
.btn{
padding: 19px 10px;
margin-bottom: 500px;
background-color: #000;
color: #fff;
border: none;
float: right;
cursor: pointer;
width: 100%;
}
.btn:hover{
background-color: #FFBB00;
color: #000;
}
.checken{
padding: 10px;
}
.select{
padding: 10px;
}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<link rel="stylesheet" href="style.css">
<style>
#import url('https://fonts.googleapis.com/css2?family=Poppins:wght#300&display=swap');
</style>
<body>
<section class="container">
<dic class="title"><h1>ITEMS VERLINKEN </h1></dic>
<form action="">
<!-- -->
<div class="parent-line">
<div class="line-link">
<div class="line"> <label class="" for=""> Link URL </label> <input class="inputFeld" type="text" name="" id="" > </div>
</div>
<div class="line-right">
<div class="line"> <label for=""> +articleNum+ </label> <input class="inputFeld" type="text" name="" id="" > </div>
</div>
</div>
<!-- -->
<div class="parent-line">
<div class="line-link">
<div class="line"> <label for=""> Full PDF name </label> <input class="inputFeld" type="text" name="" id="" placeholder="Example: test.pdf ">
</div>
</div>
<div class="line-right">
<div class="line"> <label for=""> Full PDF Links </label>
<input class="checkbox" type="checkbox" name="" id="">
</div>
</div>
</div>
<!-- -->
<div class="parent-line">
<div class="line-link">
<div class="line"> <label for=""> PDF Width in mm</label>
<input class="inputFeld" type="text" name="" id="" placeholder="Example: 212" size="4">
</div>
</div>
<div class="line-right">
<div class="line"> <label for=""> PDF Height in mm</label>
<input class="inputFeld" type="text" name="" id="" placeholder="Example: 290 " size="4">
</div>
</div>
</div>
<!-- -->
<div class="parent-line">
<div class="line-link">
<div class="line">
<label for=""> Border around links</label>
<select class="select" name="" id="">
<option value="">No</option>
<option value="">Yes</option>
</select>
</div>
</div>
<div class="line-right">
<div class="line"> <label for=""> Border(RGB):</label>
<input class="inputFeld" type="text" name="" id="" placeholder="R" size="1">
<input class="inputFeld" type="text" name="" id="" placeholder="G" size="1" >
<input class="inputFeld" type="text" name="" id="" placeholder="B" size="1">
</div>
</div>
</div>
<!-- -->
<div class="parent-line">
<div class="line-link">
<div class="line">
<label for=""> Border Width(mm)</label> <select class="select" name="" id="">
<option value="">0</option>
</select>
</div>
</div>
<div class="line-right">
<div class="line">
<label for="">Margin top (mm)</label> <select class="select" name="" id="">
<option value="">0</option>
</select>
</div>
</div>
</div>
<!-- -->
<div class="parent-one-line">
<div class="line"> <label for=""> Save settings: </label> <input class="inputFeld" type="text" name="" id="" placeholder="Example: Customer1 ">
<h5>Leave empty to prevent saving.</h5>
</div>
<input class="btn" type="button" value="Start">
</div>
</form>
</section>
</body>
</html>
Simply add align-items:center to
.parent-line .line-right{
flex: 1;
display: flex;
}
and increase/decrease input text height/font size to match the center.
I am working on a project with different browsers.
I am having a table with borders and when I zoom out my page border disappears.
This happens in all browsers like IE, EDGE, and Chrome Browser.
Is it the DOM structure problem?
It needs to supports with zoom level 75% to 125%. To be specific set zoom to 67% in Chrome and see the change
Please provide the possible solution to this question.
.mEditor {
display: flex;
border-bottom: 1px solid #d7d7d7;
}
.m-label {
width: 30%;
display: flex;
background-color: #f2f2f2;
}
.m-editor-noc {
flex: 1;
display: flex;
background-color: #FFFFFF;
border-left: 1px solid #d7d7d7;
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
}
.mfEditor {
display: flex;
flex: 1 0 auto;
}
.mEditor-li {
vertical-align: middle;
border-left: 1px solid #d7d7d7;
height: 18px;
display: inline-block;
margin-top: 3px;
}
.mEditor .tEditor {
border: none;
flex: 1;
padding-right: 6px;
}
<div class="m-group">
<div id="id251" class="mEditor">
<div class="m-label">
<label for="id223" title="Address">Address</label>
</div>
<div class="m-editor-noc">
<div id="id252" class="mfEditor">
<input type="text" class="tEditor" value="Address" name="" id="id223" maxlength="255" tabindex="0">
</div>
<div class="editor-links"></div>
</div>
</div>
<div id="id254" class="mEditor">
<div class="m-label">
<label for="id224" title="Address 2">Address 2</label>
</div>
<div class="m-editor-noc">
<div id="id255" class="mfEditor">
<input type="text" class="tEditor" value="16" name="" id="id224" maxlength="30" tabindex="0">
</div>
<div class="editor-links"></div>
</div>
</div>
<div id="id257" class="mEditor">
<div class="m-label">
<label for="id225" title="Postcode">Postcode</label>
</div>
<div class="m-editor-noc">
<div id="id258" class="mfEditor">
<input type="text" class="tEditor" value="Post Code" name="" id="id225" maxlength="10" tabindex="0">
</div>
<div class="editor-links"></div>
</div>
</div>
<div id="id25a" class="mEditor ">
<div class="m-label">
<label for="id20f" title="City">City</label>
</div>
<div class="m-editor-noc">
<div id="id25b" class="mfEditor">
<input type="text" class="tEditor" value="City" name="" id="id20f" autocomplete="off" maxlength="50" tabindex="0">
</div>
<div class="editor-links">
</div>
</div>
</div>
<div id="id25d" class="mEditor">
<div class="m-label">
<label for="id228" title="District">District</label>
</div>
<div class="m-editor-noc">
<div id="id25e" class="mfEditor">
<input type="text" class="tEditor" value="" name="" id="id228" maxlength="100" tabindex="0">
</div>
<div class="editor-links"></div>
</div>
</div>
<div id="id260" class="mEditor ">
<div class="m-label">
<label for="id210" title="Country">Country</label>
</div>
<div class="m-editor-noc">
<div id="id261" class="mfEditor">
<input type="text" class="tEditor" value="Country" name="" id="id210" autocomplete="off" maxlength="50" tabindex="0">
</div>
<div class="editor-links">
</div>
</div>
</div>
</div>
If by "We supporting all browser and Zoom level 75% - 125%" you mean you want a border to have the same size in actual pixels regardless of zoom level, you're out of luck. It's not technically possible.
You should only develop for zoom level of 100%.
There is no reliable cross-browser method to know the zoom level, which means this information is not available inside your Window object, so you can't use it to adjust values of properties on your elements.
As a fallback, you could just make the border thicker, so it will be visible even when zoomed. Now it's not displayed because it probably gets a sub-pixel size and estimated by the browser into non-renderable.
Do note everything you that's rendered at zoom levels other than 100% is entirely at the whim of how each browser internally chooses to estimate and render, which you:
have no control on
could change without notice.
In other words, your initial statement should have a minor footnote:
* Within reasonable limits. Rendering while zoomed is browser dependent.
I encountered a similar issue with border disappearing. This answer was extremely helpful to me. Draw borders by pseudo-elements. The solution for your case could be like:
.mEditor {
display: flex;
/*border-bottom: 1px solid #d7d7d7; <- REMOVE */
position: relative; /* <- ADD */
}
.mEditor::after{ /* <- ADD */
content: "";
position: absolute;
top:0;
bottom:0;
right:0;
left:0;
border-bottom: 1px solid #d7d7d7;
}
.m-label {
width: 30%;
display: flex;
background-color: #f2f2f2;
}
.m-editor-noc {
flex: 1;
display: flex;
background-color: #FFFFFF;
/*border-left: 1px solid #d7d7d7; <- REMOVE */
overflow: hidden;
white-space: nowrap;
text-overflow: ellipsis;
position: relative; /* <- ADD */
}
.m-editor-noc::after{ /* <- ADD */
content: "";
position: absolute;
top:0;
bottom:0;
right:0;
left:0;
border-left: 1px solid #d7d7d7;
}
.mfEditor {
display: flex;
flex: 1 0 auto;
}
.mEditor-li {
vertical-align: middle;
border-left: 1px solid #d7d7d7;
height: 18px;
display: inline-block;
margin-top: 3px;
}
.mEditor .tEditor {
border: none;
flex: 1;
padding-right: 6px;
}
<div class="m-group">
<div id="id251" class="mEditor">
<div class="m-label">
<label for="id223" title="Address">Address</label>
</div>
<div class="m-editor-noc">
<div id="id252" class="mfEditor">
<input type="text" class="tEditor" value="Address" name="" id="id223" maxlength="255" tabindex="0">
</div>
<div class="editor-links"></div>
</div>
</div>
<div id="id254" class="mEditor">
<div class="m-label">
<label for="id224" title="Address 2">Address 2</label>
</div>
<div class="m-editor-noc">
<div id="id255" class="mfEditor">
<input type="text" class="tEditor" value="16" name="" id="id224" maxlength="30" tabindex="0">
</div>
<div class="editor-links"></div>
</div>
</div>
<div id="id257" class="mEditor">
<div class="m-label">
<label for="id225" title="Postcode">Postcode</label>
</div>
<div class="m-editor-noc">
<div id="id258" class="mfEditor">
<input type="text" class="tEditor" value="Post Code" name="" id="id225" maxlength="10" tabindex="0">
</div>
<div class="editor-links"></div>
</div>
</div>
<div id="id25a" class="mEditor ">
<div class="m-label">
<label for="id20f" title="City">City</label>
</div>
<div class="m-editor-noc">
<div id="id25b" class="mfEditor">
<input type="text" class="tEditor" value="City" name="" id="id20f" autocomplete="off" maxlength="50" tabindex="0">
</div>
<div class="editor-links">
</div>
</div>
</div>
<div id="id25d" class="mEditor">
<div class="m-label">
<label for="id228" title="District">District</label>
</div>
<div class="m-editor-noc">
<div id="id25e" class="mfEditor">
<input type="text" class="tEditor" value="" name="" id="id228" maxlength="100" tabindex="0">
</div>
<div class="editor-links"></div>
</div>
</div>
<div id="id260" class="mEditor ">
<div class="m-label">
<label for="id210" title="Country">Country</label>
</div>
<div class="m-editor-noc">
<div id="id261" class="mfEditor">
<input type="text" class="tEditor" value="Country" name="" id="id210" autocomplete="off" maxlength="50" tabindex="0">
</div>
<div class="editor-links">
</div>
</div>
</div>
</div>
so I am working to create this really simple website, but the problem of that I put for example to elements in one and I cant make them fit their places for example:
.Form {
border: 2px solid black;
background-color: white;
margin: 1px;
float: left;
width: 50%;
white-space: nowrap;
padding: 0;
}
.Member {
width: 40%;
}
.Not_member {
width: 50%;
text-align: center;
}
fieldset {
margin: 0;
float: left;
}
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<div class="Form">
<form action="/action_page.php" method="post">
<fieldset class="Member">
<legend>Sign In</legend>
Sign in today for more experience <br><br>
<b>Email:</b> <br>
<input type="text" name="email" placeholder="Enter Email">
<br><br>
<b>Password:</b> <br>
<input type="password" name="password" placeholder="Password">
<br><br>
<input type="checkbox" name="remember" value="yes">remember me
<input type="submit" value="Log in">
</fieldset>
</form>
<fieldset class="Not_member">
<legend>Not a member ?</legend>
You can create an account:<br>
<i class="fa fa-sign-in" style="font-size:500%;color: grey;"></i>
</fieldset>
</div>
what i want to do is:
make each one fit half the container vertically and horizontally
make them stay horizontal and shrink with the container, so what i mean that when the window becomes smaller they become vertical, how can I stop that?
thanks in advance
.Form {
border: 2px solid black;
background-color: white;
margin: 1px;
float: left;
width: 100%;
white-space: nowrap;
padding: 0;
}
form{
width:55%;
}
.Member{
width:40%;
}
.Not_member {
width: 45%;
text-align: center;
padding:0;
margin:0;
}
fieldset {
margin: 0;
float: left;
}
<head>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">
</head>
<div class="Form">
<form action="/action_page.php" method="post">
<fieldset class="Member">
<legend>Sign In</legend>
Sign in today for more experience <br><br>
<b>Email:</b> <br>
<input type="text" name="email" placeholder="Enter Email">
<br><br>
<b>Password:</b> <br>
<input type="password" name="password" placeholder="Password">
<br><br>
<input type="checkbox" name="remember" value="yes">remember me
<input type="submit" value="Log in">
</fieldset>
</form>
<fieldset class="Not_member">
<legend>Not a member ?</legend>
You can create an account:<br>
<i class="fa fa-sign-in" style="font-size:500%;color: grey;"></i>
</fieldset>
</div>
I have a large number of inputs I need to display. I am trying to condense them into like groups. The first group I am have is going to have 6 inputs in 3 columns but the third input box is big, so I want the next rows input to line up with the bottom of the larger text box. Form Layout
I have tried to float them, list them, use a table, but all without successs
I have looked at a lot of CSS code snippets and cannot figure out how to get this layout. Any help would be greatly appreciated.
Edit: I found a way to make it work, but would like a more elegant solution. HTML:
.row1 {
float: left;
background-color: #ffffff;
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
font-family: Raleway, sans-serif;
text-align: center;
text-decoration: none;
padding: 5px;
}
.row2{
float: left;
background-color: #ffffff;
box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1);
font-family: Raleway, sans-serif;
text-align: center;
text-decoration: none;
padding: 5px;
}
.row3{
float: left;
display: inline-block;
clear: left;
position: relative;
margin-top: -80px;
}
<div class="row1">
<label>
<span>Full Project Number</span><br>
<input type="text" name="project" id="project">
</label>
</div>
<div class="row1">
<label>
<span>Client</span><br>
<input type="text" name="client" id="client">
</label>
</div>
</div>
<div class="row2 fasttimesatseedmonthigh">
<label id="descrp">
<span>Project Description</span><br>
<textarea name="name" type="text" cols="50" rows="10"></textarea>
</label>
</div>
<div class="row3">
<div class="row1">
<label for="drawing">
<span>Drawing Number</span><br>
<input type="text" name="drawing" id="drawing">
</label>
</div>
<div class="row1">
<label>
<span>Assigned By:</span><br>
<input type="text" name="assigned" id="assigned" style="width: 75px;">
</label>
</div>
<div class="row1">
<label class="form-row">
<span>Date</span><br>
<?php
$stamp=date("Y/m/d");?>
<input type="text" name="date" id="date" value="<?php echo(htmlspecialchars($stamp))?>"/>
</label>
</div>
</div>
It works but like I said not as nice as I would like it.
How about a good ol' table with row&colspan?
.grid{
border: solid 1px black;
table-layout: fixed;
font-family: Raleway, sans-serif;
border-spacing: 10px;
}
.grid td{
text-align: center;
vertical-align: top;
font-size: 9pt;
}
.grid td.wide{
width: 200px;
}
.grid td.normal{
width: 100px;
}
.grid td input{
width: 100%;
}
<table class="grid">
<tr>
<td colspan="2" class="wide">
<label>
<span>Full Project Number</span><br>
<input type="text" name="project" id="project">
</label>
</td>
<td colspan="2" class="wide">
<label>
<span>Client</span><br>
<input type="text" name="client" id="client">
</label>
</td>
<td colspan="2" rowspan="2">
<label id="descrp">
<span>Project Description</span><br>
<textarea name="name" type="text" cols="20" rows="8"></textarea>
</label>
</td>
</tr>
<tr>
<td colspan="1" class="normal">
<label for="drawing">
<span>Drawing Number</span><br>
<input type="text" name="drawing" id="drawing">
</label>
</td>
<td colspan="1" class="normal">
<label>
<span>Assigned By</span><br>
<input type="text" name="assigned" id="assigned">
</label>
</td>
<td colspan="2" class="wide">
<label class="form-row">
<span>Date</span><br>
<input type="text" name="date" id="date">
</label>
</td>
</tr>
</table>
Plis no hate.
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