This is what my form looks like:
My css is this:
.form select{
font-family: "Roboto", sans-serif;
outline: 0;
background: #f2f2f2;
width: 200px;
border: 0;
margin: 0 0 15 0px;
padding: 10px;
box-sizing: border-box;
font-size: 14px;
}
.form select:hover,.form select:active,.form select:focus {
background: lightgoldenrodyellow;
}
Form is this:
.form {
position: relative;
z-index: 1;
background: #FFFFFF;
max-width: 950px;
margin: 0 auto 100px;
padding: 10px;
text-align: center;
box-shadow: 0 0 20px 0 rgba(0, 0, 0, 0.2), 0 5px 5px 0 rgba(0, 0, 0, 0.24);
width: 100%;
}
How do I align this properly? Like labels should be next to drop downs on the left aligned vertically? And the drop downs should also be vertically aligned.
HTML is this:
<link rel="stylesheet" href="//code.jquery.com/ui/1.11.4/themes/smoothness/jquery-ui.css">
<script src="//code.jquery.com/jquery-1.10.2.js"></script>
<script src="//code.jquery.com/ui/1.11.4/jquery-ui.js"></script>
<link rel="stylesheet" href="style.css">
<script>
$(document).ready(function() {
$( "#datepicker" ).datepicker();
});
</script>
<p>Date: <input type="text" id="datepicker"></p>
<button onclick="printPage()" style="float:right">Print this page</button>
<form name="form" method="POST">
Select Category
<select name="category" id="category" value="category" class="form-control ddplaceholder" style="width:220px; padding-left:40px;font-size:18px;font-family:Roboto;">
<option value="" disabled selected>Select Category</option>
</select><br>
</form>
<br>
<form method="POST">
Select Item
<select name="item_name" id="item_name" value="item_name" class="form-control ddplaceholder" style="width:220px; padding-left:40px;font-size:18px;font-family:Roboto;">
<option value="" disabled selected>Select Item</option>
</select><br>
</form>
<form name="form" method="POST">
Select Vendor Name
<select name="vendor_name" id="vendor_name" value="vendor_name" class="form-control ddplaceholder" style="width:220px; padding-left:40px;font-size:18px;font-family:Roboto;">
<option value="" disabled selected>Select Vendor</option>
</select><br>
</form>
Unit <input type="text" placeholder="Unit" id="Unit"><br>
Price per Unit <input type="text" placeholder="Price per Unit" id="Price_per_Unit"><br>
Quantity <input type="text" placeholder="Quantity" id="Quantity"><br>
VAT <input type="text" placeholder="VAT" id="VAT"><br>
Freight Charges <input type="text" placeholder="Freight charges" id="Freight_charges"><br>
Other Charges <input type="text" placeholder="Other Charges" id="Other_Charges"><br>
Total <input type="text" placeholder="Total" id="Total"><br>
<form method="POST">
<input type="submit" name="submit" value="Update" style="width:150px;padding:10px;">
</form>
This has nothing to do with PHP.
Put the labels and form inputs in divs floating left with fixed width :
<div class="labelContainer">
<label for="input1">Input 1</label>
</div>
<div class="inputContainer">
<select id="input1">
<option>Option 11</option>
<option>Option 12</option>
</select>
</div>
<div class="labelContainer">
<label for="input2">Input 2</label>
</div>
<div class="inputContainer">
<select id="input2">
<option>Option 21</option>
<option>Option 22</option>
</select>
</div>
<div class="labelContainer">
<label for="input3">Input 3</label>
</div>
<div class="inputContainer">
<select id="input3">
<option>Option 31</option>
<option>Option 32</option>
</select>
</div>
CSS :
.labelContainer {
clear: both;
float: left;
width: 200px;
}
.inputContainer {
float: left;
width: 200px;
}
Fiddle
Put your form labels in tag and add "class=form-labels" to them.
then add following code to your css
h4.form-labels
{
font-family: "Roboto", sans-serif;
outline: 0;
width: 200px;
border: 0;
margin:0;
padding:0;
font-size: 14px;
display:inline-block;
}
Here a fiddle with corrections to your css: https://jsfiddle.net/vjeqfuy2/7/
Date:
Print this page
<form name="form" method="POST">
Select Category
<select name="category" id="category" value="category" class="form-control ddplaceholder">
<option value="" disabled selected>Select Category</option>
</select><br>
</form>
<br>
<form method="POST">
Select Item
<select name="item_name" id="item_name" value="item_name" class="form-control ddplaceholder" >
<option value="" disabled selected>Select Item</option>
</select><br>
</form>
<form name="form" method="POST">
Select Vendor Name
<select name="vendor_name" id="vendor_name" value="vendor_name" class="form-control ddplaceholder">
<option value="" disabled selected>Select Vendor</option>
</select><br>
</form>
Unit <input type="text" placeholder="Unit" id="Unit"><br>
Price per Unit <input type="text" placeholder="Price per Unit" id="Price_per_Unit"><br>
Quantity <input type="text" placeholder="Quantity" id="Quantity"><br>
VAT <input type="text" placeholder="VAT" id="VAT"><br>
Freight Charges <input type="text" placeholder="Freight charges" id="Freight_charges"><br>
Other Charges <input type="text" placeholder="Other Charges" id="Other_Charges"><br>
Total <input type="text" placeholder="Total" id="Total"><br>
<form method="POST">
<input type="submit" name="submit" value="Update" style="width:150px;padding:10px;">
</form>
form select{
font-family: "Roboto", sans-serif;
outline: 0;
background: #fff;
width: 200px;
border: 0;
margin: 0 0 15px 0;
padding: 10px;
box-sizing: border-box;
font-size: 14px;
height: 40px;
}
form select:hover, form select:active, form select:focus {
background: lightgoldenrodyellow;
}
Related
I have 2 questions really. How can I align my radio buttons and checkboxes to the left of my already centered form-group in css.They are currently all center, but I want the checkboxes and radio buttons to be aligned to the left, but still in center. Also how can I make my form take up the whole page with a scroll bar like the example I will provide. everything current just sits at the top of page. Please let me know of any questions, really am stuck here and just need a little nudge. Thanks.
Example: https://survey-form.freecodecamp.rocks/
.text-center {
text-align: center;
margin: auto;
}
.form-group {
text-align: center;
margin: auto;
}
.clue {
text-align: center;
}
.input-checkboxes {
text-align: center;
}
* {
box-sizing: border-box;
box-sizing: inherit;
margin: 0;
padding: 0;
font-family: lato, arial;
}
body {
background: url(images/tech2.webp);
background-size: 100%;
height: 100%;
}
.container {
grid-column: 5 / 9;
max-width: 600px;
margin: 20px auto 20px;
padding: 30px 30px 30px 30px;
border: 1px solid black;
border-radius: 8px;
background-color: rgba(255, 255, 255, 0.763);
}
header {
text-align: center;
padding-top: 20px;
padding-bottom: 20px;
}
h1 {
margin-bottom: 5px;
}
.checkbox,
.radio-button {
display: block;
}
.form-grou>.inline {
margin-right: 6px;
text-align: left;
}
#submit {
font-size: 16px;
display: block;
margin: 0 auto;
background: #2f80ed;
color: white;
border: none;
border-radius: 6px;
padding: 10px 24px;
}
#media only screen and (max-width: 1000px) {
.container {
grid-column: 1 / 12;
}
}
<header class="header">
<h1 id="title" class="text-center">Survey Form</h1>
<p id="description" class="description text-center">Thank you for taking the time to help me improve my skills as a developer</p>
</header>
<div class="container">
<form id="survey-form">
<div class="form-group">
<label id="name-label" for="name">Name:
<input
required
id="name"
for="name"
type="text"
placeholder="Name"></label><br/>
</div>
<div class="form-group">
<label id="email-label" for="email">Email:
<input
required
id="email"
type="email"
placeholder="E-mail"></label><br/>
</div>
<div class="form-group">
<label id="number-label" for="numebr">Age:
<input
required
id="number"
min="13"
max="120" type="number"
placeholder="Age"></label><br/>
</div>
<div class="form-group">
<p>Which option best describes your current role?</p>
<select for="dropdown" id="dropdown" name="role" class="form-control" required>
<option disabled selected>Seelct current role</option>
<option value="student">Student</option>
<option value="teacher">Teacher</option>
<option value="job">Full time job coding</option>
<option value="preferNo">Prefer not to say</option>
<option value="other">Other</option>
</select><br/>
</div>
<div class="form-group">
<label> Based on my portfolio/resume, would you say that I am job ready?<br/>
<input
type="radio"
name="referal"
class="inline"
value="definitely" /> Definitely</label><br/>
<label>
<input
type="radio"
name="referal"
class="inline"
value="maybe" /> Maybe</label><br/>
<label>
<input
type="radio"
name="referal"
class="inline"
value="definitelyNot"/> Definitely not
</label><br/>
</div>
<div class="form-group">
<label>In your opinion, what would you say is my strongest skill?<br/>
<select id="improved" name="improved" class="form-control" required>
<option disabled selected>Seelct an option</option>
<option value="html/css">HTML/CSS</option>
<option value="javascript">Javascript</option>
<option value="ui/ux">UI/UX Design</option>
<option value="response">Responsiveness/Functionability</option>
<option>Project Ideas</option>
</select><br/>
</label>
</div>
<div class="form-group">
<p>What would you like to see improved? <span class="clue">(Check all that apply)</span></p>
<label>
<input
type="checkbox"
name="improved"
class="input-checkbox"
value="frontend"/> Front-End skills<br/>
<input
type="checkbox"
name="improved"
class="input-checkbox"
value="backend" /> Back-End skills<br/>
<input
type="checkbox"
name="improved"
class="input-checkbox"
value="ui/ux"/> UI/UX Design<br/>
<input
type="checkbox"
name="improved"
class="input-checkbox"
value="response"/> Responsiveness/Functionality<br/>
<input
type="checkbox"
name="improved"
class="input-checkbox"
value="response" /> Project Ideas<br/>
<input
type="checkbox"
name="improved"
class="input-checkbox"
value="number"/> Number of Projects<br/>
</label>
</div>
<div class="form-group">
<p>Any other comments or suggestions?</p>
<textarea name="comments" id="comments" rows="3" cols="30" class="input-textarea" placeholder="Enter your comments here..."></textarea>
</div>
<div class="form-group">
<button type="submit" id="submit" class="submit-button">Submit
</button>
</div>
</div>
</form>
</div>
You gave the div with the radio buttons the class .form-group. This class has a property align-center if you remove that from the div the buttons will align to the left.
If you give the .text-center to the <p> the tekst will align center
.text-center{
text-align: center;
margin: auto;
}
.form-group{
text-align: center;
margin: auto;
}
.clue{
text-align: center;
}
.input-checkboxes{
text-align: center;
}
* {
box-sizing: border-box;
box-sizing: inherit;
margin: 0;
padding: 0;
font-family: lato, arial;}
body{
background: url(images/tech2.webp);
background-size: 100%;
height: 100%;
}
.container{
grid-column: 5 / 9;
max-width: 600px;
margin: 20px auto 20px;
padding: 30px 30px 30px 30px;
border: 1px solid black;
border-radius: 8px;
background-color: rgba(255, 255, 255, 0.763);
}
header{
text-align: center;
padding-top: 20px;
padding-bottom: 20px;
}
h1{
margin-bottom: 5px;
}
.checkbox, .radio-button {
display: block;
}
.form-grou > .inline {
margin-right: 6px;
text-align: left;
}
#submit {
font-size: 16px;
display: block;
margin: 0 auto;
background: #2f80ed;
color: white;
border: none;
border-radius: 6px;
padding: 10px 24px;
}
#media only screen and (max-width: 1000px) {
.container {
grid-column: 1 / 12;
}
}
<!DOCTYPE html>
<head>
<meta charset="UTF-8">
<link rel="stylesheet" href="styles.css">
<title>Survey</title>
</head>
<header class="header">
<h1 id="title" class="text-center">Survey Form</h1>
<p id="description" class="description text-center">Thank you for taking the time to help me improve my skills as a developer</p>
</header>
<div class="container">
<form id="survey-form">
<div class="form-group">
<label id="name-label" for="name">Name:
<input
required
id="name"
for="name"
type="text"
placeholder="Name"></label><br/>
</div>
<div class="form-group">
<label id="email-label" for="email">Email:
<input
required
id="email"
type="email"
placeholder="E-mail"></label><br/>
</div>
<div class="form-group">
<label id="number-label" for="numebr">Age:
<input
required
id="number"
min="13"
max="120" type="number"
placeholder="Age"></label><br/>
</div>
<div class="form-group">
<p>Which option best describes your current role?</p>
<select for="dropdown" id="dropdown" name="role" class="form-control" required>
<option disabled selected>Seelct current role</option>
<option value="student">Student</option>
<option value="teacher">Teacher</option>
<option value="job">Full time job coding</option>
<option value="preferNo">Prefer not to say</option>
<option value="other">Other</option>
</select><br/>
</div>
<div>
<label> <p class="text-center">Based on my portfolio/resume, would you say that I am job ready?<br/> </p>
<input
type="radio"
name="referal"
class="inline"
value="definitely" /> Definitely</label><br/>
<label>
<input
type="radio"
name="referal"
class="inline"
value="maybe" /> Maybe</label><br/>
<label>
<input
type="radio"
name="referal"
class="inline"
value="definitelyNot"/> Definitely not
</label><br/>
</div>
<div class="form-group">
<label>In your opinion, what would you say is my strongest skill?<br/>
<select id="improved" name="improved" class="form-control" required>
<option disabled selected>Seelct an option</option>
<option value="html/css">HTML/CSS</option>
<option value="javascript">Javascript</option>
<option value="ui/ux">UI/UX Design</option>
<option value="response">Responsiveness/Functionability</option>
<option>Project Ideas</option>
</select><br/>
</label>
</div>
<div>
<p class="text-center" >What would you like to see improved? <span class="clue">(Check all that apply)</span></p>
<label>
<input
type="checkbox"
name="improved"
class="input-checkbox"
value="frontend"/> Front-End skills<br/>
<input
type="checkbox"
name="improved"
class="input-checkbox"
value="backend" /> Back-End skills<br/>
<input
type="checkbox"
name="improved"
class="input-checkbox"
value="ui/ux"/> UI/UX Design<br/>
<input
type="checkbox"
name="improved"
class="input-checkbox"
value="response"/> Responsiveness/Functionality<br/>
<input
type="checkbox"
name="improved"
class="input-checkbox"
value="response" /> Project Ideas<br/>
<input
type="checkbox"
name="improved"
class="input-checkbox"
value="number"/> Number of Projects<br/>
</label>
</div>
<div class="form-group">
<p>Any other comments or suggestions?</p>
<textarea
name="comments"
id="comments"
rows="3"
cols="30"
class="input-textarea"
placeholder="Enter your comments here..."></textarea>
</div>
<div class="form-group">
<button
type="submit"
id="submit"
class="submit-button">Submit
</button>
</div>
</div>
</form>
</div>
Remove the css of .text-center and .form-group
(Image: https://imgur.com/a/xVxxNz1) So, as you can see, the tag is not getting the CSS properties correctly (like the name, age and number are). Could someone point out what is going wrong with my code so far? As I am new here on Stack Overflow, I would also like to know if I should have added more of my code on my post (I have just added what would be logically helpful, like the CSS styles and the tag itself). If I did that wrong, I will try to send you everything you need to help me.
#dropdown {
text-aling: center;
width: 100%;
border: 1px;
}
input,
button,
select,
textarea,
.form-control {
font-family: 'Open sans';
padding: 4px;
font-size: 70%;
margin-top: 6px;
opacity: 87%;
border: 1px;
padding-right: 10px;
padding-left: 10px;
background-color: #f9eedd;
}
<form id="survey-form">
<div>
<label id="name" for="name">Name<br>
<input type="text" name="name" id="name-label" value="" placeholder="Enter your name" required>
</label>
<br></br>
</div>
<div>
<label id="email">Email (<span class="optional">optional</span>) <br>
<input type="email" name="name" id="email-label" value="" placeholder="Enter your email" required="">
</label>
<br></br>
</div>
<div>
<label id="number">Number<br>
<input type="number" name="age" id="number-label" value="" placeholder="Age" min="10" max="99" required>
</label>
<br></br>
</div>
<p style="margin-top: -10px;">Define your current musical level:</p>
<select id="dropdown" name="role" required>
<option disabled="" selected="" value="">Select your level</option>
<option value="student">Student</option>
<option value="job">Full Time Job</option>
<option value="learner">Full Time Learner</option>
<option value="preferNo">Prefer not to say</option>
<option value="other">Other</option>
</select>
I saw that select tag also getting the CSS properties, but if you want to use the same width on the Select tag like the other fields, you need to remove the width from the dropdown. Also If you want to add some other style properties specifically only on the Select tag or any other specific tag, then you can write the CSS properties like the following way:
select#dropdown {
border: 1px solid transparent;
border-color: #fff transparent transparent transparent;
font-family: Arial;
text-align: center;
/* Write Other properties.....*/
}
Also here I am sharing one resource for your reference so that you can make a responsive form using CSS
you only specify border-width
add border: 1px solid red;
#dropdown {
text-aling: center;
width: 100%;
border: 1px solid red;
}
input,
button,
select,
textarea,
.form-control {
font-family: 'Open sans';
padding: 4px;
font-size: 70%;
margin-top: 6px;
opacity: 87%;
border: 1px;
padding-right: 10px;
padding-left: 10px;
background-color: #f9eedd;
}
<form id="survey-form">
<div>
<label id="name" for="name">Name<br>
<input type="text" name="name" id="name-label" value="" placeholder="Enter your name" required>
</label>
<br></br>
</div>
<div>
<label id="email">Email (<span class="optional">optional</span>) <br>
<input type="email" name="name" id="email-label" value="" placeholder="Enter your email" required="">
</label>
<br></br>
</div>
<div>
<label id="number">Number<br>
<input type="number" name="age" id="number-label" value="" placeholder="Age" min="10" max="99" required>
</label>
<br></br>
</div>
<p style="margin-top: -10px;">Define your current musical level:</p>
<select id="dropdown" name="role" required>
<option disabled="" selected="" value="">Select your level</option>
<option value="student">Student</option>
<option value="job">Full Time Job</option>
<option value="learner">Full Time Learner</option>
<option value="preferNo">Prefer not to say</option>
<option value="other">Other</option>
</select>
I've been trying to place my inputs and textarea on the right of the screen and my labels on the left. To try and create a structured form. At this moment I have tried using float and position but they seem to conflict and give an ugly result. Is there a better way to do this? thanks in advance :)
edit: I can't use divs for this project
form {
border: 2px solid dimgrey;
display: inline-block;
box-shadow: 5px 5px 5px 5px rgba(255, 255, 255, 0.60);;
}
input, textarea {
display: block;
box-sizing: border-box;
float: right;
}
label {
float: left;
display: inline-block;
}
<form>
<label for="naam">Je naam:</label>
<input type="text" id="naam" name="naam" size="25" maxlength="35" placeholder="Elon Musk">
<label for="email">Je e-mailadress:</label>
<input type="text" id="email" name="email" size="25" maxlength="25" placeholder="JosDePutte#gmail.com">
<label>Type vraag:
<select name="Type Vraag">
<option value="Business">Business</option>
<option value="ProductVraag">Vraag over een product</option>
<option value="Andere">Andere</option>
</select>
</label>
<label for="Vraag">Je vraag:
<textarea id="Vraag" name="Vraag" maxlength="250"></textarea>
</label>
<input type="submit" value="Verzend">
</form>
<form>
<table width="100%">
<tr>
<td>Je naam:</td>
<td align="right">
<input type="text" id="naam" name="naam" size="25" maxlength="35" placeholder="Elon Musk">
</td>
</tr>
<tr>
<td>Je e-mailadress:</td>
<td align="right">
<input type="text" id="email" name="email" size="25" maxlength="25" placeholder="JosDePutte#gmail.com">
</td>
</tr>
<tr>
<td>Type vraag:</td>
<td align="right">
<select name="Type Vraag">
<option value="Business">Business</option>
<option value="ProductVraag">Vraag over een product</option>
<option value="Andere">Andere</option>
</select>
</td>
</tr>
<tr>
<td>Je vraag:</td>
<td align="right">
<textarea id="Vraag" name="Vraag" maxlength="250"></textarea>
</td>
</tr>
</table>
</form>
it will work for you.
.form-group{display:flex;justify-content:space-between;align-items:center;margin-bottom:10px}
<form>
<div class="form-group">
<label for="naam">Je naam:</label>
<input type="text" id="naam" name="naam" size="25" maxlength="35" placeholder="Elon Musk">
</div>
<div class="form-group">
<label for="email">Je e-mailadress:</label>
<input type="text" id="email" name="email" size="25" maxlength="25" placeholder="JosDePutte#gmail.com">
</div>
<div class="form-group">
<label>Type vraag:</label>
<select name="Type Vraag">
<option value="Business">Business</option>
<option value="ProductVraag">Vraag over een product</option>
<option value="Andere">Andere</option>
</select>
</div>
<div class="form-group">
<label for="Vraag">Je vraag:</label>
<textarea id="Vraag" name="Vraag" maxlength="250"></textarea>
</div>
<input type="submit" value="Verzend">
</form>
Try This
<!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, maximum-scale=1">
<title>Document</title>
<style>
form {
border: 2px solid dimgrey;
box-shadow: 5px 5px 5px 5px rgba(255, 255, 255, 0.60);
display: flex;
flex-wrap: wrap;
}
input, textarea,select {
margin-top: 10px;
width: 70%;
border: 1px solid #eee;
padding: 0 10px
}
label {
margin-top: 10px;
width: 30%;
flex-grow: 0;
flex-shrink: 0;
}
input[type=submit] {
margin-left: 30%;
max-width: 150px;
}
</style>
</head>
<body>
<form>
<label for="naam">Je naam:</label>
<input type="text" id="naam" name="naam" size="25" maxlength="35" placeholder="Elon Musk">
<label for="email">Je e-mailadress:</label>
<input type="text" id="email" name="email" size="25" maxlength="25" placeholder="JosDePutte#gmail.com">
<label>Type vraag:</label>
<select name="Type Vraag">
<option value="Business">Business</option>
<option value="ProductVraag">Vraag over een product</option>
<option value="Andere">Andere</option>
</select>
<label for="Vraag">Je vraag:</label>
<textarea id="Vraag" name="Vraag" maxlength="250"></textarea>
<input type="submit" value="Verzend">
</form>
</body>
</html>
You should move inputs and textarea tag outside label tag and set width 50% and add some margin.
form {
border: 2px solid dimgrey;
display: inline-block;
box-shadow: 5px 5px 5px 5px rgba(255, 255, 255, 0.60);;
}
input, textarea, select {
display: block;
box-sizing: border-box;
float: right;
width: 50%;
margin: 10px;
}
label {
float: left;
display: inline-block;
width:50%;
}
<form>
<label for="naam">Je naam:</label>
<input type="text" id="naam" name="naam" size="25" maxlength="35" placeholder="Elon Musk">
<label for="email">Je e-mailadress:</label>
<input type="text" id="email" name="email" size="25" maxlength="25" placeholder="JosDePutte#gmail.com">
<label>Type vraag:
</label>
<select name="Type Vraag">
<option value="Business">Business</option>
<option value="ProductVraag">Vraag over een product</option>
<option value="Andere">Andere</option>
</select>
<label for="Vraag">Je vraag:
</label>
<textarea id="Vraag" name="Vraag" maxlength="250"></textarea>
<input type="submit" value="Verzend">
</form>
My "Reason for Contacting" and "Comment" boxes seem to be flipped and on different lines.
label {
float: left;
text-align: right;
width: 10em;
padding-right: 1em;
}
input,
textarea {
display: block;
margin-bottom: 2em;
}
input[type="submit"] {
margin-left: 6em;
}
form {
color: red;
}
<main>
<h2>Contact Us</h2>
<p>Required fields are marked with an asterisk *</p>
<form>
<label for="myName">*Name:</label>
<input type="text" id="myName" name="myName" required="required">
<label for="myEmail">*E-mail: </label>
<input type="email" id="myEmail" name="myEmail" required="required">
<label for="myPhone">Phone: </label>
<input type="tel" id="myPhone" name="myPhone">
<label for="reason">*Reason For Contacting:</label>
<select class="reason">
<option value="join">Interest in Joining</option>
<option value="sponsor">Sponsorship</option>
<option value="other">Other</option>
</select>
<label for="myComments">Comments:</label>
<textarea id="myComments" name="myComments" rows="2" cols="30"></textarea>
<input type="submit" value="Submit">
</form>
</main>
From your css I can see that you have given float: left to the label. So, the label floats left, leaving space on the right for the next element. But, the input is given display: block, which occupies the whole remaining place to right.
But the select element is display: inline by default. Hence, they seem to be mixed up. Just add display: block to select too.
label {
float: left;
text-align: right;
width: 10em;
padding-right: 1em;
}
select,/* add this */
input,
textarea {
display: block;
margin-bottom: 2em;
}
input[type="submit"] {
margin-left: 6em;
}
form {
color: red;
}
<main>
<h2>Contact Us</h2>
<p>Required fields are marked with an asterisk *</p>
<form>
<label for="myName">*Name:</label>
<input type="text" id="myName" name="myName" required="required">
<label for="myEmail">*E-mail: </label>
<input type="email" id="myEmail" name="myEmail" required="required">
<label for="myPhone">Phone: </label>
<input type="tel" id="myPhone" name="myPhone">
<label for="reason">*Reason For Contacting:</label>
<select name="reason" class="reason">
<option value="join">Interest in Joining</option>
<option value="sponsor">Sponsorship</option>
<option value="other">Other</option>
</select>
<label for="myComments">Comments:</label>
<textarea id="myComments" name="myComments" rows="2" cols="30"></textarea>
<input type="submit" value="Submit">
</form>
</main>
The issue here is because you have labels set to float: left; and elements that have no floats set at all so it's disrupting the flow.
Easiest way to fix this is to break elements up into fieldsets.
fieldset {
border: none;
width: 100%;
padding: 0;
float: left;
display: block;
}
label {
float: left;
text-align: right;
width: 10em;
padding-right: 1em;
}
input,
textarea {
display: block;
margin-bottom: 2em;
}
input[type="submit"] {
margin-left: 6em;
}
form {
color: red;
}
<main>
<h2>Contact Us</h2>
<p>Required fields are marked with an asterisk *</p>
<form>
<fieldset>
<label for="myName">*Name:</label>
<input type="text" id="myName" name="myName" required="required">
</fieldset>
<fieldset>
<label for="myEmail">*E-mail: </label>
<input type="email" id="myEmail" name="myEmail" required="required">
</fieldset>
<fieldset>
<label for="myPhone">Phone: </label>
<input type="tel" id="myPhone" name="myPhone">
</fieldset>
<fieldset>
<label for="reason">*Reason For Contacting:</label>
<select class="reason">
<option value="join">Interest in Joining</option>
<option value="sponsor">Sponsorship</option>
<option value="other">Other</option>
</select>
</fieldset>
<fieldset>
<label for="myComments">Comments:</label>
<textarea id="myComments" name="myComments" rows="2" cols="30"></textarea>
</fieldset>
<fieldset>
<input type="submit" value="Submit">
</fieldset>
</form>
</main>
Tried to find a question with an answer in this subject, but I was not able to.
I am trying to justify the input boxes and select drop down menu to the right. I tried couple of things like position and floating the label right and input and select left to no avail.
<div class="tabContainer clearfix">
<form>
<select name="selectionField" id="selectionField">
<option value="membership1">$9.95(USD) for 3 days (non-recurring)</option>
<option value="membership2">$89.95(USD) for 1 year (non-recurring)</option>
<option value="membership3">$34.95(USD) for 1 Month (recurring)</option>
</select>
<p><label for="credit_card">Credit Card #: </label>
<input type="text" name="credit_card" id="credit_card" placeholder="Credit Card Number" maxlength="16" size="20" autofocus required /></p>
<p><label for="cvv2InputField">CVV2 Number: </label>
<input type="text" name="cvv2InputField" id="cvv2InputField" maxlength="4" size="4" value onfocus="explainCVV2(this, 1)" onblur="explainCVV2(this, 0)" required /></p>
<p><label for="expirationMonth">Expires: </label>
<select name="exp_month" id="exp_month">
<option value></option>
<option value="01">01</option>
<option value="02">02</option>
<option value="03">03</option>
<option value="04">04</option>
<option value="05">05</option>
<option value="06">06</option>
<option value="07">07</option>
<option value="08">08</option>
<option value="09">09</option>
<option value="10">10</option>
<option value="11">11</option>
<option value="12">12</option>
</select>
<select name="exp_year">
<option value></option>
<option value="2014">2014</option>
<option value="2015">2015</option>
<option value="2016">2016</option>
<option value="2017">2017</option>
<option value="2018">2018</option>
<option value="2019">2019</option>
<option value="2020">2020</option>
<option value="2021">2021</option>
<option value="2022">2022</option>
<option value="2023">2023</option>
<option value="2024">2024</option>
<option value="2025">2025</option>
</select>
<p><label for="name_on_card">Name on Card: </label>
<input type="text" name="name_on_card" id="name_on_card" placeholder="Full Name" maxlength="35" size="30"/></p>
<p><label for="address1">Address: </label>
<input type="text" name="adress1" id="adress1" maxlength="35" size="30"/></p>
<p><label for="address2">City: </label>
<input type="text" name="adress2" id="adress2" maxlength="35" size="30"/></p>
<p><label for="zipcode">Postal Code: </label>
<input type="text" name="zipcode" id="zipcode" maxlength="35" size="30"/></p>
<p><label for="country">Country: </label>
<input type="text" name="country" id="country" maxlength="35" size="30"/></p>
<p><label for="email">Email Address: </label>
<input type="email" name="email" id="email" maxlength="35" size="30"/></p>
</form>
</div>
CSS
.accountSettings {
background: url("../images/searchBg.jpg") repeat scroll left top transparent;
border-bottom: 1px solid #d9d9d9;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
-o-border-radius: 6px;
-border-radius: 6px;
padding: 25px;
}
.favContent, .homeIntroWrapper {
width: 700px;
margin: -75px auto 0;
background-color: #fff;
-webkit-border-radius: 6px;
-moz-border-radius: 6px;
-o-border-radius: 6px;
border-radius: 6px;
}
.tabContainer {
background-color: #fff;
border: 1px solid #cfcfcf;
-webkit-border-radius: 0 4px 4px 4px;
-moz-border-radius: 0 4px 4px 4px;
-o-border-radius: 0 4px 4px 4px;
-border-radius: 0 4px 4px 4px;
/*margin-top: -1px;*/
padding: 20px;
position: relative;
float: left;
width: 100%;
text-decoration: bold;
-moz-box-sizing: border-box;
box-sizing: border-box;
}
Here is the fiddle http://jsfiddle.net/Lucky500/Zkvu7/
all the help would be appreciate it.
Lucky
What you can do is update your html structure to this
<div class="main-content">
<div class="left-content"></div>
<div class="right-content">
<div class="tabContainer clearfix">
// your content here
</div>
</div>
</div>
or you can add
<div class="tabContainer clearfix">
<div class="left-content"> </div>
<div class="right-content">//your input boxes comes here</div>
</div>
The add the corresponding css
.main-content {
width: 100%;
}
.left-content {
width: 30%;
display: inline-block;
}
.right-content {
width: 60%;
display: inline-block;
}
Check http://jsfiddle.net/Zkvu7/2/