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="container">
<div class="wrapper1 wrapper">
<div class="dot dot1 d11"></div>
<div class="dot dot1 d12"></div>
<div class="dot dot1 d13"></div>
</div>
<div class="wrapper2 wrapper">
<div class="dot dot2 d21"></div>
<div class="dot dot2 d22"></div>
<div class="dot dot2 d23"></div>
</div>
<div class="wrapper3 wrapper">
<div class="dot dot3"></div>
<div class="dot dot3 dot31"></div>
</div>
<div class="wrapper4 wrapper">
<div class="dot dot4"></div>
<div class="dot dot4 dot41"></div>
</div>
<div class="wrapper5 wrapper">
<div class="dot dot5 dot50"></div>
<div class="dot dot5 dot51"></div>
<div class="dot dot5 dot52"></div>
<div class="dot dot5 dot53"></div>
</div>
<div class="wrapper6 wrapper">
<div class="dot dot6 dot60"></div>
<div class="dot dot6 dot61"></div>
<div class="dot dot6 dot62"></div>
</div>
<div class="wrapper7 wrapper">
<div class="dot dot7 dot70"></div>
<div class="dot dot7 dot71"></div>
<div class="dot dot7 dot72"></div>
<div class="dot dot7 dot73"></div>
</div>
<div class="wrapper8 wrapper">
<div class="dot dot8 dot80"></div>
<div class="dot dot8 dot81"></div>
<div class="dot dot8 dot82"></div>
</div>
<div class="wrapper9 wrapper">
<div class="dot dot9"> </div>
<div class="dot dot9 dot91"> </div>
<div class="dot dot9 dot92"> </div>
<div class="dot dot9 dot93"> </div>
</div>
</div>
.container {
width: 100%;
min-height: 100vh;
display: grid;
grid-template-columns: repeat(3, 1fr);
justify-content: space-around;
align-items: center;
}
.wrapper {
width: 200px;
height: 200px;
display: flex;
justify-content: center;
align-items: center;
}
.dot {
width: 50px;
height: 50px;
border-radius: 50%;
margin-right: 10px;
}
.dot:last-child {
margin-right: 0px;
}
/* Style 1 Starts */
.dot1 {
width: 30px;
height: 30px;
background-color: #000;
}
.d11 {
animation: diagonalSlice 2s ease infinite;
}
.d12 {
animation: diagonalSlice 2s 300ms ease infinite;
}
.d13 {
animation: diagonalSlice 2s 600ms ease infinite;
}
@keyframes diagonalSlice {
0%,
100% {
transform: translateZ(-800px) rotate3d(1, 1, 0, 90deg);
opacity: 0;
}
35% {
transform: translateZ(-160px) rotate3d(1, 1, 0, 87deg) translateX(100px);
opacity: 1;
}
70% {
transform: translateZ(0) rotate3d(1, 1, 0, 0);
}
}
/* Style 1 Ends */
/* Style 2 Starts */
.wrapper2 {
perspective: 1000px;
}
.dot2 {
width: 30px;
height: 30px;
background-color: #fff;
}
.d21 {
animation: rollInOut 3s 500ms ease infinite;
}
.d22 {
animation: rollInOut 3s 1s ease infinite;
}
.d23 {
animation: rollInOut 3s 1.5s ease infinite;
}
@keyframes rollInOut {
0% {
transform: translateX(-100px) scale(0);
}
30%,
70% {
transform: translateX(0) scale(1);
background: #e76f51;
}
100% {
transform: translateX(100px) scale(0);
}
}
/* Style 2 Ends */
/* Style 3 Starts */
.wrapper3 {
perspective: 1000px;
position: relative;
}
.dot3 {
position: absolute;
width: 50px;
height: 50px;
margin: 0;
background-color: #fcbf49;
transform-origin: top right;
animation: rotate-1 3s ease infinite;
}
.dot31 {
animation-direction: reverse;
background: #d62828;
width: 40px;
height: 40px;
}
@keyframes rotate-1 {
0%,
10%,
90%,
100% {
transform: rotate(0);
}
50% {
transform: rotate(520deg) scale(0);
}
}
/* Style 3 Ends */
/* Style 4 Starts */
.wrapper4 {
position: relative;
}
.dot4 {
margin: 0;
width: 50px;
height: 50px;
background-color: #fcbf49;
transform-origin: top right;
animation: dotLeft 3s ease infinite;
}
.dot41 {
animation: dotRight 3s ease infinite;
background: #6930c3;
}
@keyframes dotLeft {
0%,
100% {
transform: rotateY(0);
transform-origin: left;
}
50% {
transform: rotateY(-70deg);
transform-origin: left;
}
}
@keyframes dotRight {
0%,
100% {
transform: rotateY(-70deg);
transform-origin: right;
}
50% {
transform: rotateY(0deg);
transform-origin: right;
}
}
/* Style 4 Ends */
/* Style 5 Starts */
.wrapper5 {
width: 100px;
position: relative;
}
.dot5 {
width: 20px;
height: 20px;
margin-right: 20px;
background-color: #fcbf49;
animation: dotMove 400ms linear infinite;
}
.dot50 {
position: absolute;
left: 0;
animation: dotScale 400ms linear infinite;
}
.dot53 {
right: 0;
animation: dotScale 400ms linear infinite reverse;
}
@keyframes dotScale {
0% {
transform: scale(0);
opacity: 0;
}
100% {
transform: scale(1);
opacity: 1;
}
}
@keyframes dotMove {
0% {
transform: translateX(0px);
}
100% {
transform: translateX(40px);
}
}
/* Style 5 Ends */
/* Style 6 Starts */
.wrapper6 {
position: relative;
}
.dot6 {
margin: 0;
position: absolute;
}
.dot60 {
width: 100px;
height: 100px;
background-color: #fcbf49;
z-index: 1;
animation: expand 3s ease infinite;
}
.dot61 {
width: 70px;
height: 70px;
background: #f77f00;
z-index: 5;
animation: expand 3s 300ms ease infinite;
}
.dot62 {
width: 40px;
height: 40px;
background: #d62828;
z-index: 10;
animation: expand 3s 600ms ease infinite;
}
@keyframes expand {
0%,
80%,
100% {
transform: scale(0);
}
40% {
transform: scale(1);
}
}
/* Style 6 Ends */
/* Style 7 Starts */
.wrapper7 {
position: relative;
}
.dot7 {
margin: 0;
position: absolute;
}
.dot70 {
width: 100px;
height: 100px;
background-color: #ffc300;
z-index: 1;
}
.dot71 {
width: 90px;
height: 90px;
background: #fff;
z-index: 5;
animation: expand7 3s linear infinite;
}
.dot72 {
width: 60px;
height: 60px;
background: #ffc300;
z-index: 10;
animation: expand71 3s 500ms ease infinite;
}
.dot73 {
width: 40px;
height: 40px;
background: #fff;
z-index: 15;
animation: expand71 3s 200ms ease infinite;
}
@keyframes expand7 {
0%,
100% {
transform: scale(0.6);
}
50% {
transform: scale(1);
}
}
@keyframes expand71 {
0%,
100% {
transform: scale(0.4);
}
50% {
transform: scale(1);
}
}
/* Style 7 Ends */
/* Style 8 Starts */
.wrapper8 {
width: 200px;
height: 100px;
position: relative;
perspective: 20px;
}
.dot8 {
position: absolute;
top: 0;
left: 0;
width: 10px;
height: 10px;
background-color: #ff006e;
animation: moveDot 2s ease infinite;
}
.dot81 {
background-color: #ffd60a;
animation: moveDot 2s 200ms ease infinite;
}
.dot82 {
background-color: #8338ec;
animation: moveDot 2s 400ms ease infinite;
}
@keyframes moveDot {
0%,
100% {
left: 0px;
top: 0;
}
30% {
top: 100%;
left: calc(50% - 10px);
}
60% {
top: 0;
left: calc(100% - 10px);
}
}
/* Style 8 Ends */
/* Style 9 Starts */
.wrapper9 {
width: 200px;
height: 200px;
position: relative;
perspective: 20px;
}
.dot9 {
width: 30px;
height: 30px;
background-color: #ff006e;
animation: effect9 2s cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}
.dot91 {
background-color: #8338ec;
animation: effect9 2s 400ms cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}
.dot92 {
background-color: #ffbe0b;
animation: effect9 2s 600ms cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}
.dot93 {
background-color: #3a86ff;
animation: effect9 2s 800ms cubic-bezier(0.215, 0.61, 0.355, 1) infinite;
}
@keyframes effect9 {
0%,
100% {
opacity: 0;
transform: translate3d(0, 3000px, 0);
}
60% {
opacity: 1;
transform: translate3d(0, -20px, 0);
}
75% {
transform: translate3d(0, 10px, 0);
}
90% {
transform: translate3d(0, -5px, 0);
}
}
/* Style 9 Ends */
Also see: Tab Triggers