Large form elements
By
Ken Hawkins
If your form is short and you'd like to focus the user with larger elements.
Contribute a pattern
Have a great way of doing something, add it to the Style Lab. Here's how
Implementation code
Get a zip with all the sample HTML and any spaecial CSS or JS needed: Download a ZIP file More on how to use this
HTML
<fieldset class="large-form">
<legend>Is your study based on human research subjects, requiring controlled access?</legend>
<input type="radio" name="pokemon" value="Red" id="pokemonRed" required><label for="pokemonRed">Yes</label>
<input checked type="radio" name="pokemon" value="Blue" id="pokemonBlue"><label for="pokemonBlue">No</label>
</fieldset>
/* Derrived from https://www.thecssninja.com/css/custom-inputs-using-css */
.large-form > {
input + label { }
input[type=radio] {
opacity: 0;
margin: 0;
margin-right: -1rem;
}
input[type=radio] + label {
font-size: 1.5rem;
line-height: 1.2rem;
}
input[type=radio] + label:before {
content: ". ";
font-family: 'EBI-Functional';
display: inline-block;
width: 1.5rem;
height: 1.5rem;
border-radius: 1.6rem;
margin: 0 .5rem .5rem 0;
text-align: center;
border: .2rem solid rgba(0,0,0,.5);
color: rgba(0,0,0,0);
}
/* Checked styles */
input[type=radio]:checked + label:before,
input[type=radio] + label:hover:before {
/* content: "/ "; */ /* checkbox */
content: "T ";
color: rgb(0,124,130);
border-color: rgba(0,0,0,0);
position: relative;
left: -3px;
}
input[type=radio]:hover:checked + label:before,
input[type=radio]:focus:checked + label:before,
input[type=radio]:checked + label:hover:before,
input[type=radio]:focus:checked + label:before { }
/* Hover & Focus styles */
input[type=radio] + label:hover:before {
color: rgba(0,0,0,.5);
}
input[type=radio]:hover + label:before,
input[type=radio]:focus + label:before,
input[type=radio] + label:hover:before { }
/* Active styles */
input[type=radio]:active + label:before,
input[type=radio] + label:hover:before:active { }
input[type=radio]:active:checked + label:before,
input[type=radio]:checked + label:hover:before:active { }
/* Disabled styles */
input[type=radio]:disabled + label:before,
input[type=radio]:hover:disabled + label:before,
input[type=radio]:focus:disabled + label:before,
input[type=radio]:disabled + label:hover:before,
input[type=radio]:disabled + label:hover:before:active { }
input[type=radio]:disabled:checked + label:before,
input[type=radio]:hover:disabled:checked + label:before,
input[type=radio]:focus:disabled:checked + label:before,
input[type=radio]:disabled:checked + label:hover:before,
input[type=radio]:disabled:checked + label:hover:before:active { }
/* Checked styles */
input[type=radio]:checked + label:before { }
input[type=radio]:hover:checked + label:before,
input[type=radio]:focus:checked + label:before,
input[type=radio]:checked + label:hover:before,
input[type=radio]:focus:checked + label:before { }
/* Hover & Focus styles */
input[type=radio]:hover + label:before,
input[type=radio]:focus + label:before,
input[type=radio] + label:hover:before { }
/* Active styles */
input[type=radio]:active + label:before,
input[type=radio] + label:hover:before:active { }
input[type=radio]:active:checked + label:before,
input[type=radio]:checked + label:hover:before:active { }
/* Disabled styles */
input[type=radio]:disabled + label:before,
input[type=radio]:hover:disabled + label:before,
input[type=radio]:focus:disabled + label:before,
input[type=radio]:disabled + label:hover:before,
input[type=radio]:disabled + label:hover:before:active { }
input[type=radio]:disabled:checked + label:before,
input[type=radio]:hover:disabled:checked + label:before,
input[type=radio]:focus:disabled:checked + label:before,
input[type=radio]:disabled:checked + label:hover:before,
input[type=radio]:disabled:checked + label:hover:before:active { }
}
.large-form > {
}
.large-form > input[type=radio] {
opacity: 0;
margin: 0;
margin-right: -1rem;
}
.large-form > input[type=radio] + label {
font-size: 1.5rem;
line-height: 1.2rem;
}
.large-form > input[type=radio] + label:before {
content: ". ";
font-family: 'EBI-Functional';
display: inline-block;
width: 1.5rem;
height: 1.5rem;
border-radius: 1.6rem;
margin: 0 .5rem .5rem 0;
text-align: center;
border: 0.2rem solid rgba(0, 0, 0, 0.5);
color: rgba(0, 0, 0, 0);
}
.large-form > input[type=radio]:checked + label:before,
.large-form > input[type=radio] + label:hover:before {
content: "T ";
color: #007c82;
border-color: rgba(0, 0, 0, 0);
position: relative;
left: -3px;
}
.large-form > input[type=radio] + label:hover:before {
color: rgba(0, 0, 0, 0.5);
}
JS