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 URL's 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 it's URL and the proper URL extention.
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 Skypack, which makes packages from npm not only available on a CDN, but prepares them for native JavaScript ES6 import
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.
<div class='component toggles'>
<input type='checkbox' id='toggle_1' />
<label for='toggle_1' class='toggle'>
<div class='thumb'></div>
</label>
<input type='checkbox' checked id='toggle_2' />
<label for='toggle_2' class='toggle'>
<div class='thumb'></div>
</label>
<input type='checkbox' id='toggle_3' />
<label for='toggle_3' class='toggle'>
<div class='thumb'></div>
</label>
<input type='checkbox' checked id='toggle_4' />
<label for='toggle_4' class='toggle'>
<div class='thumb'></div>
</label>
</div>
<div class='component radios'>
<input id='r_1' name='radio_1' type='radio' />
<label for='r_1'></label>
<input id='r_2' name='radio_1' type='radio' />
<label for='r_2'></label>
<input id='r_3' name='radio_1' type='radio' />
<label for='r_3'></label>
<hr/>
<span class='not-depress'>
<input id='r_4' name='radio_2' type='radio' />
<label for='r_4'></label>
<input id='r_5' name='radio_2' type='radio' />
<label for='r_5'></label>
<input id='r_6' name='radio_2' type='radio' />
<label for='r_6'></label>
</span>
<hr/>
<input id='r_7' name='radio_3' type='radio' />
<label for='r_7'></label>
<input id='r_8' name='radio_3' type='radio' />
<label for='r_8'></label>
<input id='r_9' name='radio_3' type='radio' />
<label for='r_9'></label>
</div>
<div class='component checkboxes'>
<input id='c_1' checked type='checkbox' />
<label for='c_1'></label>
<input id='c_2' type='checkbox' />
<label for='c_2'></label>
<input id='c_3' type='checkbox' />
<label for='c_3'></label>
<hr/>
<input id='c_4' type='checkbox' />
<label for='c_4'></label>
<input id='c_5' checked type='checkbox' />
<label for='c_5'></label>
<input id='c_6' type='checkbox' />
<label for='c_6'></label>
<hr/>
<input id='c_7' type='checkbox' />
<label for='c_7'></label>
<input id='c_8' type='checkbox' />
<label for='c_8'></label>
<input id='c_9' type='checkbox' />
<label for='c_9'></label>
</div>
<div class='component buttons'>
<button>Button</button>
<br/><br/>
<button disabled>Button</button>
<br/><br/>
<button>Button</button>
</div>
<div class='component sliders'>
<div class='ui-slider'></div>
<div class='ui-slider'></div>
<div class='ui-slider'></div>
</div>
<center class='buttons' style='clear: both;'>
<button id='animate' style='margin-top: 50px' onclick='animate()'>Animate</button>
</center>
@import compass
$green: #91C173
$red: #C27878
$blue: #37BAE8
*
box-sizing: border-box
color: #999
font: 300 12px 'Helvetica Neue', Helvetica
html, body
height: 100%
background: #DDD
hr
border: 0
border-top: 1px solid rgba(black, .1)
border-bottom: 1px solid rgba(white, .4)
.component
border-radius: 4px
float: left
padding: 20px
margin: 30px 0 0 30px
border: 1px solid rgba(black, .1)
box-shadow: 0 1px 0 rgba(white, .5)
.toggles
$h: 15px
$w: 35px
input
display: none
&:checked+.toggle
background: $green
.thumb
left: $w - $h
&:active
left: 13px
.toggle
display: block
margin: 15px 10px
width: $w
height: $h
border-radius: $h / 2
background: $red
box-shadow: inset 4px 4px 10px rgba(black, 0.2), inset 1px 1px 0 rgba(black, 0.25), 1px 1px 0 rgba(white, 0.5)
position: relative
transition: background-color .2s
transition-delay: .1s
.thumb
appearance: none
+rect($h+2)
border-radius: $h
position: absolute
left: -2px
top: -1px
+background(linear-gradient(top, #FFF, #DDD))
box-shadow: 0 0 5px rgba(black,.3), 0 8px 6px rgba(#000, .1)
cursor: pointer
outline: 0
transition: all .2s
&:active
width: 25px
left: -1px
+background(linear-gradient(bottom, #FFF, #DDD))
.radios
.not-depress input[type='radio']:checked + label
box-shadow: 0 1px 2px rgba(black, .3), inset 0 0 3px rgba(black, 0)
+background(linear-gradient(bottom, #DDD, #FFF))
input[type='radio']
display: none
+ label
display: inline-block
+circle(15px)
margin: 0 3px
+background(linear-gradient(top, #FFF, #DDD))
box-shadow: 0 1px 2px rgba(black, .3), inset 0 0 3px rgba(black, 0)
outline: 0
transition: all .2s
cursor: pointer
position: relative
&:active
transition: all .1s
+background(linear-gradient(bottom, #DDD, #FFF))
box-shadow: 0 0px 1px rgba(black, .2), inset 0 0 3px rgba(black, .2)
&:checked + label
+background(linear-gradient(top, #DDD, #FFF))
box-shadow: 0 1px 2px rgba(black, 0), inset 0 0 4px rgba(black, .3), inset 0 0 0 1px rgba(black, .1)
&:after
+circle(7px)
background: $green
+absCenter()
box-shadow: inset 0 0 3px rgba(black, .2)
content: ''
.checkboxes
input[type='checkbox']
display: none
+ label
display: inline-block
+rect(15px)
border-radius: 4px
margin: 0 3px
+background(linear-gradient(top, #FFF, #DDD))
box-shadow: 0 1px 2px rgba(black, .3), inset 0 0 3px rgba(black, 0)
outline: 0
transition: all .2s
cursor: pointer
position: relative
&:active
transition: all .1s
+background(linear-gradient(bottom, #DDD, #FFF))
box-shadow: 0 0px 1px rgba(black, .2), inset 0 0 3px rgba(black, .2)
&:checked + label
+background(linear-gradient(top, #DDD, #FFF))
box-shadow: 0 1px 2px rgba(black, 0), inset 0 0 4px rgba(black, .3), inset 0 0 0 1px rgba(black, .05)
&:after
content: ''
position: absolute
border-left: 2px solid rgba(black, .2)
border-bottom: 2px solid rgba(black, .2)
top: 28%
height: 20%
left: 20%
width: 45%
transform: rotate(-50deg)
box-shadow: -1px 1px 0 rgba(white, 1)
.buttons
button
color: #999
appearance: none
+background(linear-gradient(top, #F0F0F0, #DFDFDF))
border: 0
border-radius: 2px
line-height: 2.5em
padding: 0 35px
box-shadow: 0 1px 1px rgba(black, .1)
outline: 0
transition: box-shadow .15s, background .15s
&:not(:disabled):active, &.active
color: #9F9F9F
text-shadow: 1px 1px 0 rgba(white, .5)
+background(linear-gradient(bottom, #F0F0F0, #DFDFDF))
box-shadow: 0 1px 0 rgba(white, .7), inset 0 2px .5em rgba(black, .15), inset 0 0 0 1px rgba(black, .05)
&:disabled
color: #CFCFCF
background: #E9E9E9
cursor: not-allowed
.sliders
$h: 10px
$w: 500px
.slider, .ui-slider, .ui-slider-range
border: 0
display: block
margin: 20px 0px
width: $w
height: $h
border-radius: $h / 2
background: rgba(white, .1)
box-shadow: inset 4px 4px 10px rgba(black, 0.2), inset 1px 1px 0 rgba(black, 0.25), 1px 1px 0 rgba(white, 0.5)
position: relative
transition: background-color .2s
transition-delay: .1s
.thumb, .ui-slider-handle
appearance: none
+circle($h+6)
position: absolute
+background(linear-gradient(top, #FFF, #DDD))
box-shadow: 0 0 5px rgba(black,.3), 0 8px 6px rgba(#000, .1)
cursor: pointer
outline: 0
border: 0
transition: background .2s
&:active
+background(linear-gradient(bottom, #FFF, #DDD))
.ui-slider-range
background: $green
// Setup JQuery UI Sliders
$('.ui-slider').slider({
orientation: "horizontal",
range: "min",
animate: "normal"
});
// JS only for opening animation. Not relevant
// to menu functionality
animate();
function animate() {
$('#animate').prop('disabled', true);
$('.ui-slider').eq(0).slider('value', 33);
$('.ui-slider').eq(1).slider('value', 65);
$('.ui-slider').eq(2).slider('value', 15);
setTimeout(function() {
$('button').eq(0).addClass('active', 1000);
$('#toggle_3').click();
$('#toggle_4').click();
$('.radios input').eq(2).click();
//$('.ui-slider').eq(0).slider('value', 13);
$('.ui-slider').eq(1).slider('value', 93);
$('.ui-slider').eq(2).slider('value', 73);
}, 1000)
setTimeout(function() {
$('#toggle_1').click()
$('#toggle_3').click()
$('button').eq(0).removeClass('active', 1000);
$('button').eq(2).addClass('active', 1000);
$('.radios input').eq(3).click();
$('.ui-slider').eq(0).slider('value', 80);
$('.ui-slider').eq(1).slider('value', 22);
//$('.ui-slider').eq(2).slider('value', 10);
}, 2000)
setTimeout(function() {
$('#toggle_2').click()
$('#toggle_3').click()
$('.radios input').eq(1).click()
$('.radios input').eq(5).click()
$('button').eq(2).removeClass('active', 1000);
$('.ui-slider').eq(0).slider('value', 33);
$('.ui-slider').eq(1).slider('value', 65);
$('.ui-slider').eq(2).slider('value', 15);
}, 3000);
setTimeout(function() {
$('#animate').prop('disabled', false);
}, 4000);
}
Also see: Tab Triggers