Trying to vertically align two floated divs in a container div - css

I'm attempting to float two divs next to each other below a headline. I have tried inline-block, but the only luck I have had is making the container div display: table, and child divs as display: table-cell. I am able to align the two divs using this method, but now I have a large margin or extra padding above the "table cells." Any solution to remove extra margin/padding between the headline and child divs?
If there is a solution to not using display: table and display: table-cell, I would greatly appreciate as I only defaulted to this, because I was unable to get the floats or inline-block to vertically align with each other.
http://jsfiddle.net/jasonniebauer/GRS2k/
HTML
<div id="owner_headline">
<h3>
Owner/Officer Information
</h3>
<p>
Second Owner/Officer (optional)
</p>
</div>
<div id="owner_info">
<div id="owner_info1">
<label for="owner_name">
Name
</label>
<input type="text" id="owner_name" placeholder="Name"/>
<label for="home_address">
Home Address
</label>
<input type="text" id="home_address" placeholder="Address"/>
<label for="owner_city">
City
</label>
<input type="text" id="owner_city" placeholder="City"/>
<label for="owner_state">
State
</label>
<input type="text" id="owner_state" placeholder="State"/>
<label for="owner_zip">
Zip
</label>
<input type="text" id="owner_zip" placeholder="Zip"/>
<label for="owner_phone">
Phone
</label>
<input type="text" id="owner_phone" placeholder="Phone"/>
<label for="ownership">
Ownership
</label>
<input type="text" id="ownership" placeholder="Percentage"/>
<label>
%
</label>
<label for="ssn">
SSN
</label>
<input type="text" id="ssn" placeholder="XXX-XX-XXXX">
</div>
<div id="owner_info2">
<label for="owner_name2">
Name
</label>
<input type="text" id="owner_name2" placeholder="Name"/>
<label for="home_address2">
Home Address
</label>
<input type="text" id="home_address2" placeholder="Address"/>
<label for="owner_city2">
City
</label>
<input type="text" id="owner_city2" placeholder="City"/>
<label for="owner_state2">
State
</label>
<input type="text" id="owner_state2" placeholder="State"/>
<label for="owner_zip2">
Zip
</label>
<input type="text" id="owner_zip2" placeholder="Zip"/>
<label for="owner_phone2">
Phone
</label>
<input type="text" id="owner_phone2" placeholder="Phone"/>
<label for="ownership2">
Ownership
</label>
<input type="text" id="ownership2" placeholder="Percentage"/>
<label>
%
</label>
<label for="ssn">
SSN
</label>
<input type="text" id="ssn2" placeholder="XXX-XX-XXXX">
</div>
</div>
Css
#owner_headline {
background-color: #000B84;
}
#owner_headline h3 {
background-color: #000B84;
padding-left: 7rem;
padding-top: .5rem;
padding-bottom: .5rem;
font-family: "Bank Gothic", serif;
font-size: 24px;
display: inline-block;
color: #FFFFFF;
}
#owner_headline p {
font-family: Arial, sans-serif;
font-style: italic;
font-size: 17px;
font-weight: bold;
display: inline-block;
padding-top: 0;
padding-bottom: 0;
float: right;
padding-right: .1rem;
padding-top: .25rem;
margin-right: 1rem;
color: #FFFFFF;
}
#owner_info {
width: 912px;
display: table;
}
#owner_info1 {
width: 446px;
display: inline-block;
border: 1px solid black;
float: left;
display: table-cell;
}
#owner_info2 {
display: table-cell;
}
#owner_info1 label,
#owner_info2 label {
font-size: 14px;
}
#owner_info1 input,
#owner_info2 input {
display: inline-block;
margin-bottom: 1rem;
}
#owner_info2 {
margin-left: 1rem;
width: 446px;
display: inline-block;
border: 1px solid black;
float: left;
}
#owner_info1 input:nth-of-type(1),
#owner_info2 input:nth-of-type(1) {
width: 400px;
}
#owner_info1 input:nth-of-type(2),
#owner_info2 input:nth-of-type(2) {
width: 344px;
}
#owner_info1 input:nth-of-type(3),
#owner_info2 input:nth-of-type(3) {
width: 169px;
}
#owner_info1 input:nth-of-type(4),
#owner_info2 input:nth-of-type(4) {
width: 184px;
}
#owner_info1 label:nth-of-type(4),
#owner_info1 label:nth-of-type(6),
#owner_info1 label:nth-of-type(9),
#owner_info2 label:nth-of-type(4),
#owner_info2 label:nth-of-type(6),
#owner_info2 label:nth-of-type(9) {
margin-left: 1rem;
}
#owner_info1 input:nth-of-type(5),
#owner_info2 input:nth-of-type(5) {
width: 173px;
}
#owner_info1 input:nth-of-type(6),
#owner_info2 input:nth-of-type(6) {
width: 176px;
}
#owner_info1 input:nth-of-type(7),
#owner_info2 input:nth-of-type(7) {
width: 108px;
}
#owner_info1 input:nth-of-type(8),
#owner_info2 input:nth-of-type(8) {
width: 190px;
}

try this:
Html:
<div id="owner_headline">
<div>
<h3> Owner/Officer Information </h3>
<p>
Second Owner/Officer (optional)
</p>
</div>
<span style="clear:both;"></span>
<div id="owner_info1">
<label for="owner_name"> Name </label>
<input type="text" id="owner_name" placeholder="Name"/>
<label for="home_address"> Home Address </label>
<input type="text" id="home_address" placeholder="Address"/>
<label for="owner_city"> City </label>
<input type="text" id="owner_city" placeholder="City"/>
<label for="owner_state"> State </label>
<input type="text" id="owner_state" placeholder="State"/>
<label for="owner_zip"> Zip </label>
<input type="text" id="owner_zip" placeholder="Zip"/>
<label for="owner_phone"> Phone </label>
<input type="text" id="owner_phone" placeholder="Phone"/>
<label for="ownership"> Ownership </label>
<input type="text" id="ownership" placeholder="Percentage"/>
<label> % </label>
<label for="ssn"> SSN </label>
<input type="text" id="ssn" placeholder="XXX-XX-XXXX">
</div>
<span style="clear:both;"></span>
<div id="owner_info2">
<label for="owner_name2"> Name </label>
<input type="text" id="owner_name2" placeholder="Name"/>
<label for="home_address2"> Home Address </label>
<input type="text" id="home_address2" placeholder="Address"/>
<label for="owner_city2"> City </label>
<input type="text" id="owner_city2" placeholder="City"/>
<label for="owner_state2"> State </label>
<input type="text" id="owner_state2" placeholder="State"/>
<label for="owner_zip2"> Zip </label>
<input type="text" id="owner_zip2" placeholder="Zip"/>
<label for="owner_phone2"> Phone </label>
<input type="text" id="owner_phone2" placeholder="Phone"/>
<label for="ownership2"> Ownership </label>
<input type="text" id="ownership2" placeholder="Percentage"/>
<label> % </label>
<label for="ssn"> SSN </label>
<input type="text" id="ssn2" placeholder="XXX-XX-XXXX">
</div>
</div>
This is css:
body {
width: 912px;
}
#owner_headline {
background-color: #000B84;
}
#owner_headline h3 {
margin: 0 80px;
font-family: "Bank Gothic", serif;
font-size: 24px;
display: inline-block;
color: #FFFFFF;
}
#owner_headline p {
margin: 0 65px;
font-family: "Bank Gothic", serif;
font-size: 24px;
font-weight: bold;
display: inline-block;
padding-top: 0;
padding-bottom: 0;
color: #FFFFFF;
}
#owner_info {
width: 912px;
display: table;
}
#owner_info1 {
width: 446px;
display: inline-block;
border: 1px solid black;
float: left;
display: table-cell;
}
#owner_info2 {
display: table-cell;
}
#owner_info1 label, #owner_info2 label {
font-size: 14px;
}
#owner_info1 input, #owner_info2 input {
display: inline-block;
margin-bottom: 1rem;
}
#owner_info2 {
margin-left: 1rem;
width: 446px;
display: inline-block;
border: 1px solid black;
float: left;
}
#owner_info1 input:nth-of-type(1), #owner_info2 input:nth-of-type(1) {
width: 400px;
}
#owner_info1 input:nth-of-type(2), #owner_info2 input:nth-of-type(2) {
width: 344px;
}
#owner_info1 input:nth-of-type(3), #owner_info2 input:nth-of-type(3) {
width: 169px;
}
#owner_info1 input:nth-of-type(4), #owner_info2 input:nth-of-type(4) {
width: 184px;
}
#owner_info1 label:nth-of-type(4), #owner_info1 label:nth-of-type(6), #owner_info1 label:nth-of-type(9), #owner_info2 label:nth-of-type(4), #owner_info2 label:nth-of-type(6), #owner_info2 label:nth-of-type(9) {
margin-left: 1rem;
}
#owner_info1 input:nth-of-type(5), #owner_info2 input:nth-of-type(5) {
width: 173px;
}
#owner_info1 input:nth-of-type(6), #owner_info2 input:nth-of-type(6) {
width: 176px;
}
#owner_info1 input:nth-of-type(7), #owner_info2 input:nth-of-type(7) {
width: 108px;
}
#owner_info1 input:nth-of-type(8), #owner_info2 input:nth-of-type(8) {
width: 190px;
}

Related

Add font awesome icon on image

I need to add an icon on image onclick.
I added a border and its is shown correctly onclick but not the font awesome icon
HTML
.couleursProduits input[type=radio] {
position: absolute;
opacity: 0;
width: 0;
height: 0;
}
.couleursProduits input[type=radio] + img {
cursor: pointer;
float: left;
outline: 1px solid #d0cdcd;
outline-offset: -2px;
}
.couleursProduits input[type=radio]:checked + img {
outline: 2px solid #ceb284;
outline-offset: -2px;
}
.couleursProduits input[type=radio]:checked + img:after {
content: "\f112";
font-family: "woodmart-font";
display: inline-block;
font-size: 16px;
line-height: 50px;
font-weight: 600;
}
<label class="couleursProduits">
<input type="radio" name="couleur" value="v1">
<img width="25%" src="https://picsum.photos/id/100/367/">
</label>
<label class="couleursProduits">
<input type="radio" name="couleur" value="v2">
<img width="25%" src="https://picsum.photos/id/101/367/">
</label>
<label class="couleursProduits">
<input type="radio" name="couleur" value="v3">
<img width="25%" src="https://picsum.photos/id/102/367/">
</label>
<label class="couleursProduits">
<input type="radio" name="couleur" value="v4">
<img width="25%" src="https://picsum.photos/id/103/367/">
</label>
Full code :
https://jsfiddle.net/rxvdm8ok/

CSS Grid layout for a form

I have a div named main-filter and within the div, I have two div. Now, I want to create a form with button, labels and input and I want to put two div inside the form and it should look like the below down screenshot. I have the HTML and CSS code but it is not working and couldn't figure out how to do it with CSS grid. I need to make it responsive as well!. I am totally new at CSS grid and any help would much be appreciated. Thank you.
.main-filter {
display: flex;
margin: 0px;
padding: 20px;
height: 90px;
background-color: #eff0f2;
color: #287993;
margin-bottom: 3rem;
}
.main-header__left {
display: grid;
grid-template-columns: auto 1fr;
grid-gap: 0.3em 0.6em;
grid-auto-flow: dense;
align-items: center;
float: left;
margin-left: 250px;
margin-right: 200px;
}
.main-header__right {
display: grid;
grid-template-columns: auto 1fr;
grid-gap: 0.3em 0.6em;
grid-auto-flow: dense;
align-items: center;
float: right;
}
.filter-button1 {
background: #38acd2;
color: #FFFFFF;
max-width: 380px;
min-width: 370px;
min-height: 35px;
font-weight: bold;
}
input,
button {
grid-column: 2 / 4;
width: auto;
margin: 0;
}
input {
width: 370px;
height: 30px;
border: 1px solid #38acd2;
}
<div className="main-filter">
<form onSubmit={this.addItem}>
<div className="main-header__left">
<label className="start-timestamp">Start Timestamp: </label>
<input type="text" ref={(input4)=> this.input4 = input4} className="input-item" id="addInput3" placeholder="Ex. 2019-1-12" />
<label className="source-ip-address">Source IP Address: </label>
<input type="text" name="source" ref={(input1)=> this.input1 = input1} className="input-item" id="addInput3" placeholder="127.0.0.1 " />
<label className="service">Service Name: </label>
<input type="text" name="service" ref={(input3)=> this.input3 = input3} className="input-item" id="addInput3" placeholder="Ex. Facebook or Whatsapp *" required />
</div>
<div className="main-header__right">
<label className="end-timestamp">End Timestamp: </label>
<input type="text" ref={(input5)=> this.input5 = input5} className="input-item" id="addInput3" placeholder="Ex. 2019-1-12" />
<label className="destinatin-ip-ddress">Destination IP Address:
</label>
<input type="text" name="destination" ref={(input2)=> this.input2 = input2} className="input-item" id="addInput3" placeholder="127.0.0.1 " />
<button type="submit" className="filter-button1">Apply
Filters</button>
</div>
</form>
</div>
css grid form Image screenshot,
Try using below code, I have modified HTML and CSS code, I hope this might help you to achieve expected result.
.main-filter {
/* margin: 0px; */
/* padding: 20px; */
height: 90px;
background-color: #eff0f2;
color: #287993;
}
form {
display: grid;
grid-template-columns: auto auto;
grid-gap: 15px;
}
.main-header__left>div,
.main-header__right>div {
display: flex;
}
.main-header__left>div>label,
.main-header__right>div>label {
width: 40%;
}
#media only screen and (max-width: 500px) {
/* .main-header__left {
grid-area: 2 / span 1;
grid-gap: 0;
} */
.main-header__right {
grid-area: 2 / span 1;
grid-gap: 0;
}
}
.filter-button1 {
background: #38acd2;
color: #FFFFFF;
min-height: 35px;
font-weight: bold;
border: none;
margin-top: 18px;
width: 100%;
}
input {
width: 100%;
height: 30px;
border: 1px solid #38acd2;
}
<div className="main-filter">
<form onSubmit={this.addItem}>
<div class="main-header__left">
<div>
<label class="start-timestamp">Start Timestamp: </label>
<input type="text" />
</div>
<div>
<label className="source-ip-address">Source IP Address: </label>
<input type="text" name="source" />
</div>
<div>
<label className="service">Service Name: </label>
<input type="text" name="service" />
</div>
</div>
<div class="main-header__right">
<div>
<label className="end-timestamp">End Timestamp: </label>
<input type="text" />
</div>
<div>
<label className="destinatin-ip-ddress">Destination IP Address:</label>
<input type="text" name="destination" />
</div>
<div>
<label></label>
<button type="submit" class="filter-button1">Apply Filters</button>
</div>
</div>
</form>
</div>

HTML form field won't keep pseudoclass

I have the following form:
body {
background: #fff;
color: 404040
}
form {
display: block;
position: relative;
width: 80%;
background: #f9f9f9;
margin: 10px auto;
padding: 30px;
}
label {
display: block;
position: relative;
top: -20px;
left: 0px;
color: #999;
font-family: 'Helvetica', sans-serif;
font-size: 16px;
z-index: 1;
transition: all 0.3s ease-out;
}
input,
input:optional {
display: block;
position: relative;
background: none;
border: none;
border-bottom: 1px solid #ddd;
width: 100%;
font-family: 'Helvetica', sans-serif;
font-weight: bold;
font-size: 16px;
z-index: 2;
}
input:focus,
input:valid {
outline: none;
border-bottom: 1px solid #00aced;
}
input:focus+label,
input:required:valid+label {
top: -40px;
font-size: 11px;
color: #00aced;
}
.divider {
position: relative;
height: 30px;
width: auto;
background: none;
}
#hex1 {
width: 75px;
margin: 10px auto;
}
.headline {
margin-left: 100px;
font-size: 24px;
}
.submitBtn {
width: 250px;
height: 75px;
border-radius: 3px;
background: #37afac;
margin: 0 auto;
color: #fff
}
#title {
margin-top: -60px;
margin-left: 80px;
margin-bottom: 20px;
}
<form>
<h3>Details about the person you are reporting:</h3>
<div class='divider'></div>
<input type="text" name="firstname" required autocomplete="off" />
<label for="firstname">First Name</label>
<div class='divider'></div>
<input type="text" name="lastname" required autocomplete="off" />
<label for="lastname">Last Name</label>
<div class='divider'></div>
<input type="text" name="age" class="test" autocomplete="off" />
<label for="age">Age</label>
<div class='divider'></div>
<input type="text" name="gender" required autocomplete="off" />
<label for="gender">Gender</label>
<div class='divider'></div>
<input type="text" name="address 1" autocomplete="off" />
<label for="address1">Address 1</label>
<div class='divider'></div>
<input type="text" name="address 2" autocomplete="off" />
<label for="address2">Address 2</label>
<div class='divider'></div>
<input type="text" name="city" required autocomplete="off" />
<label for="city">City</label>
<div class='divider'></div>
<input type="text" name="state" required autocomplete="off" />
<label for="state">State</label>
<div class='divider'></div>
<input type="text" name="position" autocomplete="off" />
<label for="Position">Position (coach, referee, etc)</label>
<div class='divider'></div>
<input type="text" name="program" required autocomplete="off" />
<label for="Program">Program where individual works</label>
<div class='divider'></div>
<input type="text" name="IncidentDescription" required autocomplete="off" />
<label for="IncidentDescription">Incident description</label>
<div class='divider'></div>
<input type="text" name="IncidentLocation" required autocomplete="off" />
<label for="IncidentLocation">Incident location</label>
<div class='divider'></div>
Codepen: https://codepen.io/anon/pen/PazrBw
As each input receives focus, it animates via receiving a class in css. Using basic html5 validation, it's supposed to retain that class to show that it's been properly filled out.
My problem is that I need some fields to be not required. When fields are not marked required, the form automatically applies some of the :valid pseudoclass (the blue underline). The even bigger issue is that when it loses focus, it loses that class and collapses the label back down onto the input text.
What am I missing here? thank you!
You are not missing anything, it all behaves the way it's supposed to be based on your code. So you need an alternative approach.
I suggest using :placeholder-shown selector instead of :valid. This way, empty optional fields will no longer get selected.
To make this work, you first need to add placeholder=" " to your inputs. This feels a bit hacky because this way you are losing the ability to use placeholders in case you need them but remember that you are already saying no to using placeholders by putting labels in their place (well, if you ever need to include placeholders for the sake of accessibility, do it, and instead of empty placeholders put real ones, then hide them with CSS. Another topic, another time).
:placeholder-shown does not have IE/old browser support so we'll go with a good example of progressive enhancement here:
Label text will be already minimised and positioned on top of the input as a default (that is top: -40px; font-size: 11px;) so that it does not mess with user input. I believe that is good enough for IE/old browsers.
Then we add the nice animation effect for browsers that do support :placeholder-shown by including following styles:
input:not(:focus):placeholder-shown + label {
top: -20px;
font-size: 16px;
}
:not(:focus) is necessary to resize and reposition label as soon as user focuses an input because some browsers show placeholder even after focus (and hide it only after user starts typing).
body {
background: #fff;
color: 404040
}
form {
display: block;
position: relative;
width: 80%;
background: #f9f9f9;
margin: 10px auto;
padding: 30px;
}
label {
display: block;
position: relative;
/* top: -20px; */
top: -40px;
left: 0px;
color: #999;
font-family: 'Helvetica', sans-serif;
/* font-size: 16px; */
font-size: 11px;
z-index: 1;
transition: all 0.3s ease-out;
}
input/*,
input:optional */ {
display: block;
position: relative;
background: none;
border: none;
border-bottom: 1px solid #ddd;
width: 100%;
font-family: 'Helvetica', sans-serif;
font-weight: bold;
font-size: 16px;
z-index: 2;
}
input:focus/*,
input:valid*/ {
outline: none;
border-bottom: 1px solid #00aced;
}
input:focus+label/*,
input:required:valid+label*/ {
color: #00aced;
}
/* New styles >> */
input:not(:focus):placeholder-shown + label {
top: -20px;
font-size: 16px;
}
/* << */
.divider {
position: relative;
height: 30px;
width: auto;
background: none;
}
#hex1 {
width: 75px;
margin: 10px auto;
}
.headline {
margin-left: 100px;
font-size: 24px;
}
.submitBtn {
width: 250px;
height: 75px;
border-radius: 3px;
background: #37afac;
margin: 0 auto;
color: #fff
}
#title {
margin-top: -60px;
margin-left: 80px;
margin-bottom: 20px;
}
<form>
<h3>Details about the person you are reporting:</h3>
<div class='divider'></div>
<input placeholder=" " type="text" name="firstname" required autocomplete="off" />
<label for="firstname">First Name</label>
<div class='divider'></div>
<input placeholder=" " type="text" name="lastname" required autocomplete="off" />
<label for="lastname">Last Name</label>
<div class='divider'></div>
<input placeholder=" " type="text" name="age" class="test" autocomplete="off" />
<label for="age">Age</label>
<div class='divider'></div>
<input placeholder=" " type="text" name="gender" required autocomplete="off" />
<label for="gender">Gender</label>
<div class='divider'></div>
<input placeholder=" " type="text" name="address 1" autocomplete="off" />
<label for="address1">Address 1</label>
<div class='divider'></div>
<input placeholder=" " type="text" name="address 2" autocomplete="off" />
<label for="address2">Address 2</label>
<div class='divider'></div>
<input placeholder=" " type="text" name="city" required autocomplete="off" />
<label for="city">City</label>
<div class='divider'></div>
<input placeholder=" " type="text" name="state" required autocomplete="off" />
<label for="state">State</label>
<div class='divider'></div>
<input placeholder=" " type="text" name="position" autocomplete="off" />
<label for="Position">Position (coach, referee, etc)</label>
<div class='divider'></div>
<input placeholder=" " type="text" name="program" required autocomplete="off" />
<label for="Program">Program where individual works</label>
<div class='divider'></div>
<input placeholder=" " type="text" name="IncidentDescription" required autocomplete="off" />
<label for="IncidentDescription">Incident description</label>
<div class='divider'></div>
<input placeholder=" " type="text" name="IncidentLocation" required autocomplete="off" />
<label for="IncidentLocation">Incident location</label>
<div class='divider'></div>

After Submit button is hit hide form and have 'thank you' box appear

After the user fills out this from and clicks the submit button located at the bottom, I would like the form to disappear and have a 'thank you' box appear in it's place. If anyone knows how to complete this please let me know!
JSFiddle
<form class="container" action="https://webto.salesforce.com/servlet/servlet.WebToLead?encoding=UTF-8" method="POST">
<label>First Name
<input id="first_name" maxlength="40" name="first_name" size="20" type="text" onkeyup="test()" required><i class="fa fa-check-circle" aria-hidden="true"></i>
</label>
<label>Last Name
<input id="last_name" maxlength="80" name="last_name" size="20" type="text" onkeyup="test()"><i class="fa fa-check-circle" aria-hidden="true"></i>
</label>
<label>Email
<span class="error">Please enter a valid email address</span>
<input id="email" maxlength="80" name="email" size="20" type="text" onkeyup="test()"><i class="fa fa-times-circle-o" aria-hidden="true"></i>
</label>
<label>Phone
<span class="error">Please enter a valid phone number</span>
<input id="phone" maxlength="80" name="phone" size="20" type="tel" onkeyup="test()"><i class="fa fa-times-circle-o" aria-hidden="true"></i>
</label>
<label>City
<input id="city" name="city" maxlength="40" size="20" type="text" onkeyup="test()"><i class="fa fa-check-circle" aria-hidden="true"></i>
</label>
<label>State/Province
<input id="state" maxlength="20" name="state" size="20" type="text" onkeyup="test()"><i class="fa fa-check-circle" aria-hidden="true"></i>
</label>
<label id="co">Company
<input id="company" name="company" type="text" onkeyup="test()"><i class="fa fa-check-circle" aria-hidden="true"></i>
</label>
<label>Comments
<textarea id="comments" name="" id="" cols="30" rows="10" onkeyup="test()"></textarea>
<input id="sub" type="submit" disabled="disabled" />
</label>
<div>
<select hidden="true" id="00N6A000008yXMN" name="00N6A000008yXMN" title="Product Interest">
<option value="">--None--</option>
<option selected="selected" value="Visiant">Visiant</option>
<option value="Tessellate">Tessellate</option>
</select><br>
<select hidden="true" id="lead_source" name="lead_source">
<option value="">--None--</option>
<option value="Internal">Internal</option>
<option value="Trade Show">Trade Show</option>
<option selected="selected" value="Website">Website</option>
<option value="Direct Marketing">Direct Marketing</option>
<option value="Social Media">Social Media</option>
<option value="Other">Other</option>
</select><br>
</div>
</form>
body {
color: #fff;
background-color: #f78e2a;
text-align: center;
}
form {
color: #fff;
background-color: #f78e2a;
text-align: center;
font-family: Lato;
}
* {
box-sizing: border-box;
}
.form-title {
font-size: 38px;
color: #fff;
font-family: "Lato";
letter-spacing: 70px;
}
input[type="tel"] {
width: 100%;
height: 85%;
padding: 10px;
background-color: #f9a558;
border: 1px solid #fff;
}
input[type="text"] {
width: 100%;
padding: 10px;
background-color: #f9a558;
border: 1px solid #fff;
}
input[type="text"]:focus {
background-color: #fff;
}
input[type="text"]:visited {
background-color: #fff;
}
input[type="tel"]:focus {
background-color: #fff;
}
input[type="tel"]:visited {
background-color: #fff;
}
.container {
display: flex;
flex-direction: column;
padding: 5px 0;
margin-left: 10%;
margin-right: 10%;
}
textarea {
width: 100%;
background-color: #f9a558;
border: 1px solid #fff;
}
textarea:focus {
background-color: #fff;
}
#co {
flex-basis: 100%;
max-width: 100%;
}
label:nth-last-child(-n+2) {
flex-basis: 100%;
max-width: 100%;
}
select,
label {
height: 50px;
width: 48%;
margin: 2% 1%;
text-align: left;
font-family: "Lato";
}
#sub {
border-radius: 6px;
width: 120px;
height: 35px;
text-transform: uppercase;
display: block;
margin-top: 10px;
}
button {
margin-top: 10px;
background-color: #B9B9B9;
color: #959595;
border-radius: 6px;
width: 120px;
height: 35px;
margin-left: 1%;
display: block;
}
button:focus {
background-color: #fff;
color: #f78e2a;
}
#media (max-width: 426px) {
label {
width: 98%;
}
}
#media (min-width: 426px) {
.container {
flex-direction: row;
flex-wrap: wrap;
align-self: flex-start;
}
}
label {
position: relative;
}
.fa {
position: absolute;
bottom: 0;
right: 0;
transform: translate(-50%, -5%);
opacity: 0;
transition: opacity .5s, color .5s;
}
[data-valid] .fa {
opacity: 1;
color: green;
}
[data-valid="valid"] .fa {
color: green;
}
[data-valid="error"] .fa {
color: red;
}
.error {
display: none;
color: red;
font-size: .7em;
position: absolute;
left: 10px;
top: 0;
transform: translateY(150%);
}
[data-valid="error"] .error {
display: block;
}
function phoneNumber(phone) {
var phoneno = /^\d{9}|\d{10}|\d{11}$/;
console.log("PHONE: "+phoneno.test(phone));
return phoneno.test(phone);
}
$('input[type="tel"]').on('keyup', function() {
var $label = $(this).closest('label');
if ($(this).val().trim() != '') {
if ($(this).is('#phone')) {
if (phoneNumber($(this).val())) {
$label.attr('data-valid', 'valid');
$(this).next("i").removeClass("fa-times-circle-o").addClass("fa-check-circle");
} else {
$label.attr('data-valid', 'error');
console.log("this works");
$(this).next("i").removeClass("fa-check-circle").addClass("fa-times-circle-o");
}
} else {
$label.attr('data-valid', 'valid');
console.log("this works")
}
} else {
$label.removeAttr('data-valid');
console.log("this works")
}
});
function validateEmail(email) {
var re = /^(([^<>()[\]\\.,;:\s#\"]+(\.[^<>()[\]\\.,;:\s#\"]+)*)|(\".+\"))#((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/;
console.log("email: "+re.test(email));
return re.test(email);
}
$('input[type="text"]').on('keyup', function() {
var $label = $(this).closest('label');
if ($(this).val().trim() != '') {
if ($(this).is('#email')) {
if (validateEmail($(this).val())) {
$label.attr('data-valid', 'valid');
$(this).next("i").removeClass("fa-times-circle-o").addClass("fa-check-circle");
} else {
$label.attr('data-valid', 'error');
console.log("this works 1")
$(this).next("i").removeClass("fa-check-circle").addClass("fa-times-circle-o");
}
} else {
$label.attr('data-valid', 'valid');
console.log("this works 2");
}
} else {
$label.removeAttr('data-valid');
console.log("this works 3");
}
});
test = function() {
if ($("#first_name").val()
&& $("#last_name").val()
&& $("#email").val()
&& $("#phone").val()
&& $("#city").val()
&& $("#state").val()
&& $("#company").val()) {
$("#sub").removeAttr("disabled");
}
}
Have you considered using bootstrap? It's a fantastic framework that makes tasks like this super easy.

CSS overflow : How to fix css overflow scroll bug

I am working on creating a page which has a fixed links on the top and fixed submit buttons at the bottom. The content in between is scrollable using overflow:auto;
I am noticing, when I reduce the browser window size the scroller slowly disappears.
How can I fix this? Are there any hacks?
I am working Firefox 19.0 and chrome version 26.0.1410.12 and IE9
Here is my code in its entirety:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>overflow based Layout</title>
<style type="text/css">
<!--
/* Pretty Stuff
================================== */
/* Zero down margin and paddin on all elements */
* {
margin: 0;
padding: 0;
}
body {
font: 92.5%/1.6"Lucida Grande", "Lucida Sans", "Lucida Sans Unicode", Verdana, sans-serif;
}
h1 {
font-size: 2.4em;
font-weight: normal;
}
h2 {
font-size: 2.0em;
font-weight: normal;
}
p, li {
font-size: 1.4em;
}
h1, h2, p {
margin: 1em 0;
}
#branding h1 {
margin: 0;
}
#wrapper {
background-color: #fff;
}
#branding {
height: 50px;
background-color:#b0b0b0;
padding: 20px;
}
#form-b {
height: 500px;
overflow: auto;
position: fixed;
top: 164px;
width: 98%;
}
#mainNav {
list-style: none;
background-color:#eee;
}
#footer {
background-color:#b0b0b0;
padding: 1px 20px;
}
/* The Core Technique
================================= */
body {
text-align: center;
min-width: 1260px;
}
#wrapper {
width: 100%;
margin: 0 auto;
text-align: left;
}
#content {
width: 100%;
float: right;
}
#mainNav li {
/* width: 180px;
float: left; */
display:inline;
}
#submit-b {
border: 0px solid red;
bottom: 77px;
position: fixed;
text-align: cemter;
width: 100%;
}
#footer {
clear: both;
}
/* Add some padding
================================== */
#mainNav {
padding-top: 20px;
padding-bottom: 20px;
position: fixed;
width: 100%;
}
#mainNav * {
padding-left: 20px;
padding-right: 20px;
}
#mainNav * * {
padding-left: 0;
padding-right: 0;
}
#content * {
padding-right: 20px;
}
#content * * {
padding-right: 0;
}
-->
/* fieldset styling */
fieldset {
margin: 1em 0;
/* space out the fieldsets a little*/
padding: 1em;
border : 1px solid #ccc;
background-color:#F5F5F5
}
/* legend styling */
legend {
font-weight: bold;
}
form p {
position: relative;
width: 100%;
}
/* style for labels */
label {
float: left;
width: 10em;
}
#remember-me label {
width: 4em;
}
/* style for required labels */
label .required {
font-size: 0.83em;
color:#760000;
}
/* style error messages */
label .feedback {
position: absolute;
margin-left: 11em;
left: 200px;
right: 0;
font-weight: bold;
color:#760000;
padding-left: 18px;
background: url(images/error.png) no-repeat left top;
}
/* :KLUDGE: Explicitly set the width for IE6- */
* html .feedback {
width: 10em;
}
input {
width: 200px;
}
input[type="text"], textarea {
border-top: 2px solid #999;
border-left: 2px solid #999;
border-bottom: 1px solid #ccc;
border-right: 1px solid #ccc;
}
input.radio, input.checkbox, input.submit {
width: auto;
}
/* style form elements on focus */
input:focus, textarea:focus {
background: #ffc;
}
input.radio {
float: left;
margin-right: 1em;
}
textarea {
width: 300px;
height: 100px;
}
/* Date of Birth form styling */
#monthOfBirthLabel, #yearOfBirthLabel {
text-indent: -1000em;
width: 0;
}
#dateOfBirth {
width: 3em;
margin-right: 0.5em;
}
#monthOfBirth {
width: 10em;
margin-right: 0.5em;
}
#yearOfBirth {
width: 5em;
}
/* Color form styling */
#favoriteColor {
margin: 0;
padding: 0;
border: none;
background: transparent;
}
#favoriteColor h2 {
width: 10em;
float: left;
font-size: 1em;
font-weight: normal;
}
#favoriteColor div {
width: 8em;
float: left;
}
#favoriteColor label {
/*width: 3em;*/
float: none;
display: inline;
}
</style>
</head>
<body>
<div id="wrapper">
<div id="branding">
<h1>Branding</h1>
</div>
<div id="content">
<ul id="mainNav">
<li class="first">
Home
</li>
<li>
About
</li>
<li>
News
</li>
<li>
Products
</li>
<li>
Services
</li>
<li>
Clients
</li>
<li>
Case Studies
</li>
</ul>
<div id="form-b">
<form id="comments_form" action="#" method="post">
<fieldset>
<legend>Your Contact Details</legend>
<p>
<label for="author">Name: <span class="required">(Required)</span>
</label>
<input name="author" id="author" type="text" />
</p>
<p>
<label for="email">Email Address: <span class="feedback">Incorrect email address. Please try again.</span>
</label>
<input name="email" id="email" type="text" />
</p>
<p>
<label for="url">Web Address:</label>
<input name="url" id="url" type="text" />
</p>
</fieldset>
<fieldset>
<legend>Your Contact Details</legend>
<p>
<label for="author">Name: <span class="required">(Required)</span>
</label>
<input name="author" id="author" type="text" />
</p>
<p>
<label for="email">Email Address: <span class="feedback">Incorrect email address. Please try again.</span>
</label>
<input name="email" id="email" type="text" />
</p>
<p>
<label for="url">Web Address:</label>
<input name="url" id="url" type="text" />
</p>
</fieldset>
<fieldset>
<legend>Your Contact Details</legend>
<p>
<label for="author">Name: <span class="required">(Required)</span>
</label>
<input name="author" id="author" type="text" />
</p>
<p>
<label for="email">Email Address: <span class="feedback">Incorrect email address. Please try again.</span>
</label>
<input name="email" id="email" type="text" />
</p>
<p>
<label for="url">Web Address:</label>
<input name="url" id="url" type="text" />
</p>
</fieldset>
<fieldset>
<legend>Your Contact Details</legend>
<p>
<label for="author">Name: <span class="required">(Required)</span>
</label>
<input name="author" id="author" type="text" />
</p>
<p>
<label for="email">Email Address: <span class="feedback">Incorrect email address. Please try again.</span>
</label>
<input name="email" id="email" type="text" />
</p>
<p>
<label for="url">Web Address:</label>
<input name="url" id="url" type="text" />
</p>
</fieldset>
<fieldset id="submit-b">
<legend></legend>
<p>
<input id="submit" class="submit" name="submit" type="submit" />
</p>
</fieldset>
</form>
</div>
</div>
<div id="footer">
<p>Footer</p>
</div>
</div>
</body>
</html>
Reduce the padding to 10px:
#content * {
padding-right: 10px; /* Line 106 */
}

Resources