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.
<div class="scale">
<div class="wrapper">
<div class="cube">
<h class="front">front</h>
<h class="back">back</h>
<h class="top">top</h>
<h class="bottom">bottom</h>
<h class="left">left</h>
<h class="right">right</h>
<k class="front"></k>
<k class="back"></k>
<k class="top"></k>
<k class="bottom"></k>
<k class="left"></k>
<k class="right"></k>
</div>
</div>
</div>
<div class="logo">
<svg version="1.0" xmlns="http://www.w3.org/2000/svg"
width="200.000000pt" height="137.000000pt" viewBox="0 0 100.000000 499.000000"
preserveAspectRatio="xMidYMid meet">
<g transform="translate(0,200) scale(0.100000,-0.100000)"
fill="#c00" stroke="none">
<g class="all">
<g class="over">
<path d="M1412 1018 c-8 -8 -12 -47 -12 -108 0 -61 4 -100 12 -108 7 -7 44
-12 97 -12 l86 0 72 -72 c71 -71 73 -74 73 -123 0 -50 -1 -52 -78 -128 l-77
-77 -81 0 c-49 0 -85 -5 -92 -12 -16 -16 -16 -200 0 -216 16 -16 200 -16 216
0 7 7 12 35 12 63 l0 50 108 108 107 107 51 0 c27 0 55 5 62 12 16 16 16 200
0 216 -7 7 -40 12 -78 12 l-65 0 -93 93 c-89 89 -92 94 -92 138 0 25 -5 50
-12 57 -16 16 -200 16 -216 0z"/>
</g>
<g class="less">
<path d="M200 813 l-180 -178 0 -45 c0 -44 1 -46 158 -202 148 -147 161 -158
196 -158 48 0 86 36 86 81 0 28 -17 49 -122 156 l-122 123 142 143 c125 125
142 146 142 175 0 45 -38 82 -84 82 -32 0 -51 -16 -216 -177z"/>
</g>
<g class="pen">
<path d="M1171 1285 l-115 -73 -1 -90 -1 -90 53 -26 54 -26 49 39 c28 22 59
43 70 46 19 6 20 15 20 151 0 79 -3 144 -7 143 -5 0 -59 -34 -122 -74z"/>
<path d="M976 974 c-9 -20 -16 -37 -14 -39 2 -1 38 -20 80 -43 l77 -41 21 33
c11 18 20 36 20 39 0 6 -150 87 -161 87 -3 0 -13 -16 -23 -36z"/>
<path d="M932 888 c-21 -26 -222 -426 -307 -612 -58 -127 -84 -197 -81 -211 7
-26 56 -50 84 -41 25 8 428 683 465 778 5 14 -7 25 -56 52 -82 46 -92 49 -105
34z"/>
</g>
</g>
</g>
</svg>
</div>
body{
background: lightgoldenrodyellow;
}
.logo{
margin: 1em;
position: fixed;
bottom: -72px;
z-index: 99999999999;
right: 0;
}
.scale{
perspective:400px;
transform-style:preserve-3d;
transform: rotateX(-22deg);
}
/* keyframes for rotating animation */
@-webkit-keyframes spin {
from { transform: rotateY(0); }
to { transform: rotateY(360deg); }
}
/* scene wrapper */
.wrapper{
height: 300px;
margin-top:120px;
position:relative;
perspective: 800px;
perspective-origin: 50% 100px;
}
/* cube wrapper */
.cube{
position: relative;
margin: 0 auto;
width: 200px;
transform-style: preserve-3d;
animation: spin 4s infinite linear;
transition: all 1s linear;
top:150px;
}
/* outer cube */
h{
position:absolute;
width:200px;
height:200px;
display:block;
background:rgba(255,255,255,0.1);
box-shadow:inset 0 0 30px rgba(0,0,0,0.2);
font-size:20px;
text-align:center;
line-height:200px;
color:rgba(0,0,0,0.5);
font-family:sans-serif;
text-transform:uppercase;
transition: all 1s linear;
}
h.back{
transform: translateZ(-100px) rotateY(180deg);
}
h.right{
transform:rotateY(-270deg) translateX(100px);
transform-origin: top right;
}
h.left{
transform:rotateY(270deg) translateX(-100px);
transform-origin: center left;
}
h.top{
transform:rotateX(90deg)translateZ(100px);
}
h.bottom{
transform:rotateX(90deg) translateY(100px);
transform-origin: bottom center;
}
h.front{
transform: translateZ(100px);
}
/* inner cube */
k{
position:absolute;
top:50px;
left:50px;
width:100px;
height:100px;
display:block;
background:darkred;
transition: all 1s linear;
}
k.front{
transform: translateZ(50px);
}
k.back{
transform: translateZ(-50px) rotateY(180deg);
}
k.bottom{
transform:rotateX(-90deg) translateY(50px);
transform-origin: left bottom;
}
k.left{
transform:rotateY(270deg) translateX(-50px);
transform-origin: center left;
}
k.right{
transform:rotateY(-270deg) translateX(50px);
transform-origin: top right;
}
k.top{
transform:rotateX(-270deg) translateY(-50px);
transform-origin: right top;
}
/* hover transformations */
.cube:hover{
top:150px;
}
.cube:hover h.top{
transform: translateZ(-100px) rotateX(175deg);
transform-origin: top ;
}
.cube:hover k{
top:-200px;
}
svg{
}
.pen{
fill:black;
animation:rotateInDownLeft 3s forwards;
}
.all{
animation:rotateOut 3s forwards;
}
@keyframes rotateInDownLeft {
from {
transform-origin: left bottom;
transform: rotate3d(0,0,0, 0deg);
opacity: 1;
}
to {
-webkit-transform-origin: left bottom;
transform-origin: left bottom;
transform: ;
transform:translateX(850px) translateY(-83px) rotate3d(0,0,1, -60deg);
opacity: 1;
}
}
@keyframes rotateOut {
from {
-webkit-transform-origin: center;
transform-origin: center;
opacity: 1;
}
to {
-webkit-transform-origin: center;
transform-origin: center;
-webkit-transform: rotate3d(0, 0, 1, 90deg);
transform: rotate3d(0, 0, 1, 90deg);
opacity: 1;
}
}
Also see: Tab Triggers