HTML preprocessors can make writing HTML more powerful or convenient. For instance, Markdown is designed to be easier to write and read for text documents and you could write a loop in Pug.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. So you don't have access to higher-up elements like the <html>
tag. If you want to add classes there that can affect the whole document, this is the place to do it.
In CodePen, whatever you write in the HTML editor is what goes within the <body>
tags in a basic HTML5 template. If you need things in the <head>
of the document, put that code here.
The resource you are linking to is using the 'http' protocol, which may not work when the browser is using https.
CSS preprocessors help make authoring CSS easier. All of them offer things like variables and mixins to provide convenient abstractions.
It's a common practice to apply CSS to a page that styles elements such that they are consistent across all browsers. We offer two of the most popular choices: normalize.css and a reset. Or, choose Neither and nothing will be applied.
To get the best cross-browser support, it is a common practice to apply vendor prefixes to CSS properties and values that require them to work. For instance -webkit-
or -moz-
.
We offer two popular choices: Autoprefixer (which processes your CSS server-side) and -prefix-free (which applies prefixes via a script, client-side).
Any URLs added here will be added as <link>
s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.
You can apply CSS to your Pen from any stylesheet on the web. Just put a URL to it here and we'll apply it, in the order you have them, before the CSS in the Pen itself.
You can also link to another Pen here (use the .css
URL Extension) and we'll pull the CSS from that Pen and include it. If it's using a matching preprocessor, use the appropriate URL Extension and we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
JavaScript preprocessors can help make authoring JavaScript easier and more convenient.
Babel includes JSX processing.
Any URL's added here will be added as <script>
s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.
You can apply a script from anywhere on the web to your Pen. Just put a URL to it here and we'll add it, in the order you have them, before the JavaScript in the Pen itself.
If the script you link to has the file extension of a preprocessor, we'll attempt to process it before applying.
You can also link to another Pen here, and we'll pull the JavaScript from that Pen and include it. If it's using a matching preprocessor, we'll combine the code before preprocessing, so you can use the linked Pen as a true dependency.
Search for and use JavaScript packages from npm here. By selecting a package, an import
statement will be added to the top of the JavaScript editor for this package.
Using packages here is powered by esm.sh, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ESM usage.
All packages are different, so refer to their docs for how they work.
If you're using React / ReactDOM, make sure to turn on Babel for the JSX processing.
If active, Pens will autosave every 30 seconds after being saved once.
If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.
If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.
Visit your global Editor Settings.
<form class="topLabel">
<header class="form-header">
<h2>A Form of Fantasy</h2>
<div class="quote">
"The gift of fantasy has meant more to me than my talent for absorbing positive knowledge." <span>- Albert Einstein</span>
</div>
</header>
<div class="form-progress">
<div class="progress">
<span id="progress-width"></span>
</div>
</div>
<ul>
<li class="form-section enabled">
<div id="form-field-1" class="span_one_two">
<fieldset>
<legend>
Which is better?
</legend>
<div>
<span>
<input id="Field1_0" name="Field1" type="radio" class="field radio" value="Fantasty" checked="checked" />
<label class="choice" for="Field1_0" >
Fantasty
</label>
</span>
<span>
<input id="Field1_1" name="Field1" type="radio" class="field radio" value="Sci-Fi" />
<label class="choice" for="Field1_1" >
Sci-Fi
</label>
</span>
<span>
<input id="Field1_2" name="Field1" type="radio" class="field radio" value="Don't make me choose!" />
<label class="choice" for="Field1_2" >
Don't make me choose!
</label>
</span>
<span>
<input id="Field1_3" name="Field1" type="radio" class="field radio" value="I don't like either" />
<label class="choice" for="Field1_3" >
I don't like either
</label>
</span>
</div>
</fieldset>
</div>
<div id="form-field-2" class="span_two_two">
<label class="title" id="title2" for="Field2">
How much would you donate to a Kickstarter to bring back Firefly?
</label>
<span class="symbol">$</span>
<span>
<input id="Field2" name="Field2" type="text" class="field text currency nospin" value="" size="10" />
<label for="Field2">Dollars</label>
</span>
<span class="symbol radix">.</span>
<span class="cents">
<input id="Field2-1" name="Field2-1" type="text" class="field text nospin" value="" size="2" maxlength="2" />
<label for="Field2-1">Cents</label>
</span>
</div>
</li>
<li class="likert form-section disabled">
<table cellspacing="0">
<caption class="title" id="title3">
Rate the Star Wars movies
</caption>
<thead>
<tr>
<th> </th>
<td>Didn't Like At All</td>
<td>Meh</td>
<td>Kinda Liked</td>
<td>Loved!</td>
</tr>
</thead>
<tbody>
<tr class="statement3">
<th>
<label for="Field3">Episode I - The Phantom Menace</label>
</th>
<td title="Didn't Like At All">
<input id="Field3_1" name="Field3" type="radio" value="Didn't Like At All" />
<label for="Field3_1">1</label>
</td>
<td title="Meh">
<input id="Field3_2" name="Field3" type="radio" value="Meh" />
<label for="Field3_2">2</label>
</td>
<td title="Kinda Liked">
<input id="Field3_3" name="Field3" type="radio" value="Kinda Liked" />
<label for="Field3_3">3</label>
</td>
<td title="Loved!">
<input id="Field3_4" name="Field3" type="radio" value="Loved!" />
<label for="Field3_4">4</label>
</td>
</tr>
<tr class="alt statement4" id="form-field-3" >
<th>
<label for="Field4">Episode II - Attack of the Clones</label>
</th>
<td title="Didn't Like At All">
<input id="Field4_1" name="Field4" type="radio" value="Didn't Like At All" />
<label for="Field4_1">1</label>
</td>
<td title="Meh">
<input id="Field4_2" name="Field4" type="radio" value="Meh" />
<label for="Field4_2">2</label>
</td>
<td title="Kinda Liked">
<input id="Field4_3" name="Field4" type="radio" value="Kinda Liked" />
<label for="Field4_3">3</label>
</td>
<td title="Loved!">
<input id="Field4_4" name="Field4" type="radio" value="Loved!" />
<label for="Field4_4">4</label>
</td>
</tr>
<tr class="statement5" id="form-field-4" >
<th><label for="Field5">Episode III - Revenge of the Sith</label></th>
<td title="Didn't Like At All">
<input id="Field5_1" name="Field5" type="radio" value="Didn't Like At All" />
<label for="Field5_1">1</label>
</td>
<td title="Meh">
<input id="Field5_2" name="Field5" type="radio" value="Meh" />
<label for="Field5_2">2</label>
</td>
<td title="Kinda Liked">
<input id="Field5_3" name="Field5" type="radio" value="Kinda Liked" />
<label for="Field5_3">3</label>
</td>
<td title="Loved!">
<input id="Field5_4" name="Field5" type="radio" value="Loved!" />
<label for="Field5_4">4</label>
</td>
</tr>
<tr class="alt statement6" id="form-field-5" >
<th>
<label for="Field6">Episode IV - A New Hope</label>
</th>
<td title="Didn't Like At All">
<input id="Field6_1" name="Field6" type="radio" value="Didn't Like At All" />
<label for="Field6_1">1</label>
</td>
<td title="Meh">
<input id="Field6_2" name="Field6" type="radio" value="Meh" />
<label for="Field6_2">2</label>
</td>
<td title="Kinda Liked">
<input id="Field6_3" name="Field6" type="radio" value="Kinda Liked" />
<label for="Field6_3">3</label>
</td>
<td title="Loved!">
<input id="Field6_4" name="Field6" type="radio" value="Loved!" />
<label for="Field6_4">4</label>
</td>
</tr>
<tr class="statement7" id="form-field-6" >
<th>
<label for="Field7">Episode V - The Empire Strikes Back</label>
</th>
<td title="Didn't Like At All">
<input id="Field7_1" name="Field7" type="radio" value="Didn't Like At All" />
<label for="Field7_1">1</label>
</td>
<td title="Meh">
<input id="Field7_2" name="Field7" type="radio" value="Meh" />
<label for="Field7_2">2</label>
</td>
<td title="Kinda Liked">
<input id="Field7_3" name="Field7" type="radio" value="Kinda Liked" />
<label for="Field7_3">3</label>
</td>
<td title="Loved!">
<input id="Field7_4" name="Field7" type="radio" value="Loved!" />
<label for="Field7_4">4</label>
</td>
</tr>
<tr class="alt statement8" id="form-field-7" >
<th>
<label for="Field8">Episode VI - Return of the Jedi</label>
</th>
<td title="Didn't Like At All">
<input id="Field8_1" name="Field8" type="radio" value="Didn't Like At All" />
<label for="Field8_1">1</label>
</td>
<td title="Meh">
<input id="Field8_2" name="Field8" type="radio" value="Meh" />
<label for="Field8_2">2</label>
</td>
<td title="Kinda Liked">
<input id="Field8_3" name="Field8" type="radio" value="Kinda Liked" />
<label for="Field8_3">3</label>
</td>
<td title="Loved!">
<input id="Field8_4" name="Field8" type="radio" value="Loved!" />
<label for="Field8_4">4</label>
</td>
</tr>
</tbody>
</table>
</li>
<li class="form-section disabled">
<div id="form-field-8" class="span_one_two">
<label class="desc title" id="title104" for="Field104">
Are you caught up on Game of Thrones?
</label>
<div>
<select id="Field104" name="Field104" class="field select medium" tabindex="31" >
<option value="Never seen it" selected="selected">
Never seen it
</option>
<option value="Yep, totally caught up" >
Yep, totally caught up
</option>
<option value="I've seen some but I'm not caught up" >
I've seen some but I'm not caught up
</option>
</select>
</div>
</div>
<div id="form-field-9" class="span_two_two">
<label class="desc title" id="title107" for="Field107">
What is your favorite Fantasty or Sci-Fi movie of all time?
</label>
<div>
<input id="Field107" name="Field107" type="text" class="field text medium" value="" maxlength="255" tabindex="32" onkeyup="" />
</div>
</div>
</li>
<li class="disabled">
<div class="form">
<section>
<h3 id="title108" class="title">
Your Information
</h3>
</section>
<div id="form-field-10">
<label class="desc" id="title105" for="Field105">
Name
</label>
<span>
<input id="Field105" name="Field105" type="text" class="field text fn" value="" size="8" tabindex="33" />
<label for="Field105" class="label-sub">First</label>
</span>
<span>
<input id="Field106" name="Field106" type="text" class="field text ln" value="" size="14" tabindex="34" />
<label for="Field106" class="label-sub">Last</label>
</span>
</div>
<div id="form-field-11">
<label class="desc" id="title110" for="Field110">
Email
</label>
<div>
<input id="Field110" name="Field110" type="email" spellcheck="false" class="field text medium" value="" maxlength="255" />
</div>
</div>
<div id="form-field-12">
<label class="desc" id="title117" for="Field117">
Website
</label>
<div>
<input id="Field117" name="Field117" type="url" class="field text medium" value="" maxlength="255" tabindex="36" />
</div>
</div>
<input id="saveForm" name="saveForm" class="btTxt submit" type="submit" value="Submit"/>
</div>
</li>
<a id="next-section" class="next-section">Next Section</a>
</ul>
</form>
@import "compass/css3";
/* ---------- Functions ---------- */
@function emCalc($pxWidth) {
@return $pxWidth / $em-base * 1em;
}
/* ---------- Web Fonts ---------- */
@import url(https://fonts.googleapis.com/css?family=Josefin+Slab:600,400|Source+Sans+Pro:300);
$font-family-serif: 'Josefin Slab', Palatino, "Palatino Linotype", "Palatino LT STD", "Book Antiqua", Georgia, serif;
$font-family-sans: 'Source Sans Pro', Tahoma, Verdana, Segoe, sans-serif;
$em-base: 16px;
/* ---------- Colors ---------- */
$white: #FFF;
$white-dark: #cecec8;
$cream: #f8f9f6;
$grey: #3d3d3d;
$grey-lighten: adjust_hue(lighten(#3d3d3d, 24), 0);
$grey-darken: adjust_hue(darken($grey, 11), 0);
$blue: #48dce5;
$blue-darken: darken(#48dce5, 12);
/* ---------- Universal selectors ---------- */
* { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; }
/* ---------- Text Highlight ---------- */
::selection {
background: $grey-lighten;
color: $white;
}
::-moz-selection {
background: $grey-lighten;
color: $white;
}
/* ---------- Placeholders ---------- */
%title {
display: block;
padding: 0 0 emCalc(18px);
width: 90%;
color: $grey;
text-transform: uppercase;
letter-spacing: emCalc(1px);
font-weight: 300;
font-size: emCalc(20px);
font-family: $font-family-sans;
}
/* ---------- Grid ---------- */
.span_one_two{
float: left;
width: 50%;
}
.span_two_two{
@extend .span_one_two;
}
/* ---------- General Elements ---------- */
body {
padding: emCalc(25px);
color: $grey-lighten;
font-weight: 300;
font-family: $font-family-sans;
}
h2 {
margin: 0 0 emCalc(10px);
color: $grey-darken;
text-transform: uppercase;
letter-spacing: emCalc(2px);
font-weight: 600;
font-size: emCalc(30px);
font-family: $font-family-serif;
}
h3 {
margin: 0;
}
/* ---------- Progress Bar ---------- */
.form-progress {
padding: 0 emCalc(25px);
background-color: $cream;
}
.progress {
display: block;
overflow: hidden;
width: 100%;
height: emCalc(40px);
border-radius: (emCalc(10px));
background-color: $grey;
box-shadow: inset emCalc(1px) emCalc(4px) emCalc(9px) emCalc(3px) $grey-darken;
transition: width .5s ease-in-out;
span {
float:left;
width: 0;
height: 100%;
background-color: $blue;
box-shadow: inset emCalc(1px) emCalc(4px) emCalc(9px) emCalc(3px) $blue-darken;
transition: width .5s ease-in-out;
}
}
/* ---------- Form Header ---------- */
.form-header {
margin: 0;
padding: emCalc(25px) emCalc(25px) emCalc(40px);
background-color: $cream;
text-align: center;
}
.quote {
color: $grey-lighten;
font-style: italic;
span {
display: block;
width: 100%;
font-style: normal;
}
}
/* ---------- Form ---------- */
form {
margin: 0 auto;
padding: 0 0 emCalc(25px);
max-width: 75%;
border-radius: (emCalc(10px));
transition: max-width .3s ease-out, background-color .25s ease-out;
&:hover {
transition: background-color .5s ease-in;
}
ul {
position: relative;
margin: 0;
padding: 0 0 emCalc(25px);
}
li {
position: relative;
clear: both;
width: 100%;
background-color: $cream;
list-style: none;
-webkit-transition:all 1s ease-in-out;
-moz-transition:all 1s ease-in-out;
-o-transition:all 1s ease-in-out;
transition:all 1s ease-in-out;
-webkit-transform-origin: 50% 100%;
-ms-transform-origin: 50% 100%;
transform-origin: 50% 100%;
-webkit-backface-visibility: hidden;
-moz-backface-visibility: hidden;
-ms-backface-visibility: hidden;
}
.disabled{
visibility: hidden;
height: 0;
-webkit-transform:rotateX(90deg);
-moz-transform:rotateX(90deg);
-o-transform:rotateX(90deg);
transform:rotateX(90deg);
}
.enabled {
padding: emCalc(30px);
height: auto;
-webkit-transform:rotateX(0deg);
-moz-transform:rotateX(0deg);
-o-transform:rotateX(0deg);
transform:rotateX(0deg);
}
input {
padding: emCalc(5px);
border: emCalc(1px) solid $white-dark;
border-radius: emCalc(5px);
color: $grey-lighten;
transition: border 1s ease-out,padding .25s ease-out;
&:focus {
padding-right: emCalc(15px);
border:1px solid $blue;
transition: border .4s ease-in, padding .1s ease-in;
}
}
legend {
@extend %title;
}
fieldset {
display: block;
margin: 0;
padding: 0;
border: none;
}
.submit {
transition: background-color .25s ease-out, color .3s ease-out;
text-transform: uppercase;
font-size: emCalc(16px);
&:hover {
background-color: $grey-lighten;
color: $white;
transition: background-color .25s ease-in, color .3s ease-in;
}
}
.form-section {
float:left;
margin: 0;
border-bottom: emCalc(4px) solid $white;
}
.form{
margin: 0 auto;
div {
display: block;
float:left;
margin: 0 0 emCalc(15px);
width: 100%;
}
input{
width:100%;
}
label{
display: block;
width: 100%;
}
.label-sub {
color: #bdbdbd;
}
span{
float: left;
width: 50%;
input{
width: 80%;
}
}
}
}
/* ---------- Table ---------- */
table {
width: 100%;
border: emCalc(1px) solid $white-dark;
td {
padding: 0.25em;
width: emCalc(130px);
border-left: emCalc(1px) solid $white-dark;
text-align: center;
}
tr {
transition: background-color .5s ease-out;
&:hover {
background-color: #f3f3f3;
transition: background-color .25s ease-in;
}
}
th,
td {
border-bottom: emCalc(1px) solid $white-dark;
font-weight: 300;
}
caption {
text-align: left;
}
tbody {
td label {
display: block;
}
th {
padding: emCalc(8px);
text-align: left;
}
}
thead {
td {
padding: emCalc(10px) emCalc(6px);
}
td, th {
background-color: $grey-lighten;
color: $white;
text-transform: uppercase;
}
}
}
/* ---------- Misc ---------- */
.choice {
display: block;
margin: emCalc(-20px) 0 0 emCalc(25px);
padding: 0 0 emCalc(10px) 0;
cursor: pointer;
}
.title {
@extend %title;
table & {
display: table-caption;
}
}
.next-section{
display: block;
margin: 0 auto;
padding: emCalc(5px) 0;
width: 25%;
border-radius: emCalc(15px);
background-color: $grey-lighten;
color: $white;
text-align: center;
text-transform: uppercase;
font-size: emCalc(20px);
cursor: pointer;
transition: .25s background-color ease-out;
&:hover {
background-color: $grey;
transition: .4s background-color ease-in;
}
}
/* ---------- Media Queries ---------- */
@media only screen and (max-width: 600px) {
.span_one_two,
.span_two_two{
margin: 0 0 emCalc(25px);
width: 100%;
}
}
@media only screen and (max-width: 1120px) {
form {
max-width: 100%;
}
}
$(document).ready(function() {
var form_section_total = 0;
var form_section_names = [];
var next_section = $('#next-section');
var total_sections = $('li').length -1;
//Store all form field sections in an array
$("[id^=form-field]").each(function() {
//Push id values to array with id #
form_section_names.push('#' + $(this).attr('id'));
//Calc the length of the array
form_section_total = form_section_names.length;
});
next_section.on('click', function(e) {
var currentEnabled = $('.enabled').last(); //Latest section to be enabled
var totalEnabled = $('.enabled').length; //Number of enabled sections
currentEnabled.next('.disabled').removeClass('disabled').addClass('enabled');
//Hide Next buton if all sections are enabled
if ( totalEnabled === total_sections ) {
next_section.fadeOut();
}
//Update Progress bar
progressBar(totalEnabled,total_sections);
});
function progressBar (enabled,totalSections) {
var currentPercentage = enabled / totalSections * 100;
$('#progress-width').css('width',currentPercentage + "%");
}
});
Also see: Tab Triggers