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.
main
header.accessible-hide
h1 CSS 403 Error
.flexy-center
.button__container
#connect.button Connect
#reload.button.button--disabled Reload
#container.container
svg#computer.computer.svg-icon(xmlns='http://www.w3.org/2000/svg', width='1024', height='1024', viewbox='0 0 1024 1024')
path(d='M864 159.872L160 160c-17.696 0-32 14.176-32 31.872v448c0 17.696 14.304 32 32 32h704c17.696 0 32-14.304 32-32v-448c0-17.696-14.304-32-32-32zM864 640H160V191.872h704V640zm64-608H96C42.976 32 0 74.944 0 128v640c0 52.928 42.816 95.808 95.68 95.936H416v38.944l-199.744 25.952C201.984 932.384 192 945.184 192 959.872c0 17.696 14.304 32 32 32h576c17.696 0 32-14.304 32-32 0-14.688-9.984-27.488-24.256-31.072L608 902.88v-38.944h320.32c52.864-.128 95.68-43.008 95.68-95.936V128c0-53.056-43.008-96-96-96zm32 736c0 17.632-14.368 32-32 32H96c-17.664 0-32-14.368-32-32V128c0-17.664 14.336-32 32-32h832c17.632 0 32 14.336 32 32v640z')
svg#server.server.svg-icon(xmlns='http://www.w3.org/2000/svg', width='1024', height='1024', viewbox='0 0 1024 1024')
path(d='M512 0C296.192 0 64 65.056 64 208v608c0 142.88 232.192 208 448 208 215.776 0 448-65.12 448-208V208C960 65.056 727.744 0 512 0zm384 816c0 79.488-171.936 144-384 144-212.096 0-384-64.512-384-144V696.448C194.112 764.576 353.6 800 512 800s317.888-35.424 384-103.552V816zm0-192h-.128c0 .32.128.672.128.992C896 704 724.064 768 512 768s-384-64-384-143.008c0-.32.128-.672.128-.992H128V504.448C194.112 572.576 353.6 608 512 608s317.888-35.424 384-103.552V624zm0-192h-.128c0 .32.128.672.128.992C896 512 724.064 576 512 576s-384-64-384-143.008c0-.32.128-.672.128-.992H128V322.048C211.872 385.952 365.6 416 512 416s300.128-30.048 384-93.952V432zm-384-80c-212.096 0-384-64.512-384-144 0-79.552 171.904-144 384-144 212.064 0 384 64.448 384 144 0 79.488-171.936 144-384 144zm256 480c0-17.673 14.327-32 32-32s32 14.327 32 32c0 17.673-14.327 32-32 32s-32-14.327-32-32zm0-192c0-17.673 14.327-32 32-32s32 14.327 32 32c0 17.673-14.327 32-32 32s-32-14.327-32-32zm0-192c0-17.673 14.327-32 32-32s32 14.327 32 32c0 17.673-14.327 32-32 32s-32-14.327-32-32z')
#response.response
.item 4
.item 0
.item 3
.sparks
#container__title.container__title Forbidden
@charset 'utf-8';
@import 'compass/reset';
@import url('https://fonts.googleapis.com/css?family=Bree+Serif');
@import url('https://fonts.googleapis.com/css?family=Open+Sans:300');
$white : #ecf0f1;
$black : #1f1f1f;
$lightGray : #cfcfcf;
$red : #e74c3c;
$blue : #2c3e50;
$green : #27ae60;
$baseDuration: .45s;
$fastDuration: $baseDuration / 2;
$slowDuration: $baseDuration * 2;
$lineHeight: 1.4rem;
$basePadding: $lineHeight;
html,
body,
main {
height: 100%;
width: 100%;
box-sizing: border-box;
-webkit-overflow-scrolling: touch;
}
body {
font-size: 1em;
line-height: $lineHeight;
color: $white;
background-color: $blue;
font-family: 'Open Sans', sans-serif;
}
.accessible-hide {
position: absolute;
height: 0;
width: 0;
overflow: hidden;
}
.flexy-center {
height: 100%;
display: flex;
align-items: center;
justify-content: center;
flex-direction: column;
}
.svg-icon {
width: 1em;
height: 1em;
fill: $white;
&:nth-of-type(1) {
transform: translate(-.55em);
}
&:nth-of-type(2) {
transform: translate(.55em);
}
}
.button {
padding: ($lineHeight / 2) $lineHeight;
border-radius: .2em;
background-color: $green;
margin: 0 $lineHeight;
transition: all $fastDuration ease-in-out;
cursor: pointer;
&__container {
display: flex;
}
&--disabled {
pointer-events: none;
opacity: .2;
}
}
$itemWidth: .7em;
$boxWidth : 3em;
$containerWidth: 5em;
$totalDuration: $slowDuration;
$queryDelay: ($totalDuration * 70) / 100;
$queryDuration: $totalDuration - $queryDelay;
$responseDelay: ($totalDuration * 95) / 100;
.container {
font-size: 3em;
height: .45em;
width: $containerWidth;
margin-top: ($lineHeight * 5);
perspective: 1200px;
position: relative;
display: flex;
align-items: flex-end;
justify-content: space-between;
background-image: radial-gradient($white .015em, transparent .02em);
background-size: .25em .25em;
background-repeat: repeat-x;
background-position: 0 bottom;
transition: all ($slowDuration * 3) ease-in-out;
&__title {
margin-top: 1em;
font-size: 2em;
opacity: 0;
transition: opacity $fastDuration ease-in-out;
&--anim {
opacity: 1;
}
}
&__anim {
background-position: 200% bottom;
}
&:before {
content: '';
height: 1em;
width: calc(100% + .15em);
position: absolute;
left: -.075em;
bottom: -.48em;
box-sizing: border-box;
padding-bottom: .25em;
border-radius: 0 0 .25em .25em;
border: .05em solid white;
border-bottom-color: transparent;
border-top-color: transparent;
transform-style: preserve-3d;
transform-origin: 50% 0;
transform: rotateX(63deg);
}
&__jump {
.response {
animation: responseMove ($slowDuration * 1.25) ease-out forwards;
.item {
opacity: 1;
animation: $slowDuration linear forwards;
animation-delay: $fastDuration / 2;
&:nth-child(1) {
animation-name: jump4;
}
&:nth-child(2) {
animation-name: jump0;
}
&:nth-child(3) {
animation-name: jump3;
}
}
.sparks {
transform: scale(2);
opacity: 0;
background-color: $red;
}
}
.server {
fill: $red;
}
background-image: radial-gradient($red .015em, transparent .02em);
&:before {
border-right-color: $red;
}
}
.svg-icon {
position: absolute;
bottom: 100%;
&:nth-of-type(1) {
left: 0;
}
&:nth-of-type(2) {
right: 0;
}
}
}
.response {
position: absolute;
right: -.5em;
top: -1em;
.item {
opacity: 0;
line-height: 1em;
font-family: 'Bree Serif', serif;
}
}
.sparks {
width: 1em;
height: 1em;
border-radius: 1em;
background-color: white;
transform: scale(0);
transition: all $fastDuration ease-out;
}
.item {
top: 0;
right: 0;
position: absolute;
width: $itemWidth;
z-index: 2;
text-align: center;
transition: all $baseDuration ease-out;
display: flex;
align-items: center;
line-height: .87em;
justify-content: center;
}
@keyframes responseMove {
100% {
transform: translate(-2.5em, .7em) scale(1.5);
}
}
@keyframes jump4 {
0% {
transform: translateY(0) translateX(0) rotate(0);
animation-timing-function: ease-out;
}
50% {
transform: translateY(-3em) translateX(-.35em) rotate(-340deg);
animation-timing-function: ease-in;
}
70% {
transform: translateY(0) translateX(-.45em) rotate(-360deg);
animation-timing-function: ease-out;
}
80% {
transform: translateY(-1em) translateX(-.55em) rotate(-360deg);
animation-timing-function: ease-in;
}
90%,
100% {
transform: translateY(0) translateX(-.65em) rotate(-360deg);
animation-timing-function: ease-out;
color: $red
}
}
@keyframes jump0 {
0% {
transform: translateY(0) translateX(0) rotate(0);
animation-timing-function: ease-out;
}
50% {
transform: translateY(-2em) translateX(-.1em) rotate(-700deg);
animation-timing-function: ease-in;
}
70% {
transform: translateY(0) translateX(-.1em) rotate(-720deg);
animation-timing-function: ease-out;
}
80% {
transform: translateY(-.5em) translateX(-.1em) rotate(-720deg);
animation-timing-function: ease-in;
}
90%,
100% {
transform: translateY(0) translateX(-.1em) rotate(-720deg);
animation-timing-function: ease-out;
color: $red
}
}
@keyframes jump3 {
0% {
transform: translateY(0) translateX(0) rotate(0);
animation-timing-function: ease-out;
}
50% {
transform: translateY(-3em) translateX(.1em) rotate(-340deg);
animation-timing-function: ease-in;
}
70% {
transform: translateY(0) translateX(.2em) rotate(-360deg);
animation-timing-function: ease-out;
}
80% {
transform: translateY(-1em) translateX(.3em) rotate(-360deg);
animation-timing-function: ease-in;
}
90%,
100% {
transform: translateY(0) translateX(.4em) rotate(-360deg);
animation-timing-function: ease-out;
color: $red
}
}
var computer = $('#computer'),
response = $('#response'),
connect = $('#connect'),
reload = $('#reload'),
container = $('#container'),
containerTit = $('#container__title');
connect.click(function() {
$(this).toggleClass('button--disabled');
reload.toggleClass('button--disabled');
container.addClass('container__anim');
container.one('webkitTtransitionEnd otransitionend msTransitionEnd transitionend', function() {
container.addClass('container__jump');
container.one('webkitAnimationEnd oanimationend msAnimationEnd animationend', function() {
containerTit.addClass('container__title--anim')
});
});
});
reload.click(function() {
$(this).toggleClass('button--disabled');
connect.toggleClass('button--disabled');
container.removeClass('container__anim');
container.removeClass('container__jump');
containerTit.removeClass('container__title--anim');
});
Also see: Tab Triggers