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.
<h2>Squash and Stretch</h2>
<div class="flex__grid">
<!-- Gives physical appearance during interaction -->
<button class="btn btn--squash-stretch">Continue</button>
</div>
<h2>Anticipation</h2>
<div class="flex__grid">
<!-- Draws attention to user to prepare them for a bigger action -->
<button class="btn btn--anticipation">Subscribe</button>
</div>
<h2>Staging</h2>
<div class="flex__grid">
<!-- Projecting the intentions of the element to a user -->
<button class="btn btn--staging">Loading</button>
</div>
<h2>Pose 2 Pose/Straight Ahead</h2>
<div class="flex__grid">
<!-- Showing the user a change in form for leading across the interface or new feature that's accessible -->
<button class="btn btn--pose-2-pose">Loading</button>
</div>
<h2>Follow through/Overlap</h2>
<div class="flex__grid">
<!-- Staggering motion of the main element as other pieces react to the motion change -->
<button class="btn btn--follow-through">Submit</button>
</div>
<h2>Slow in & Slow out</h2>
<div class="flex__grid">
<!-- Defining a natural motion by slowing the animation and speeding it up during an element/feature introduction -->
<button class="btn btn--slow-in-out">Continue</button>
</div>
<h2>Arcs</h2>
<div class="flex__grid">
<!-- Gives variety and natural motion to elements -->
<button class="btn btn--arcs">Begin</button>
</div>
<h2>Secondary Action</h2>
<div class="flex__grid">
<!-- Other elements react to primary actions to give more personality to main animation -->
<button class="btn btn--secondary-action">Wait!</button>
<button class="btn btn--secondary-action--sibling">Wait!</button>
<button class="btn">Wait!</button>
</div>
<h2>Timing</h2>
<div class="flex__grid">
<!-- Set up proper fast or slow animations with extending the time or shortening it, does a user need to see it for 5 seconds or a quarter second -->
<button class="btn btn--fast">Fast</button>
<button class="btn btn--slow">Slow</button>
</div>
<h2>Exaggeration</h2>
<div class="flex__grid">
<!-- If this element's motion is mimiced to real life, give it excessive values to close out it's animation to call attention and bring user's focus to the action -->
<button class="btn btn--exaggeration">Continue</button>
</div>
<h2>Solid Drawings</h2>
<div class="flex__grid">
<!-- Element is presented in a consistent 3D nature to give weight and space -->
<button class="btn btn--solid">Continue</button>
</div>
<h2>Appeal</h2>
<div class="flex__grid">
<!-- Motion has personality and light hearted motion to connect with the user -->
<button class="btn btn--appeal">Continue</button>
</div>
<h4><a href="https://vimeo.com/93206523" target="_blank">The Illusion of Life</a></h4>
body {
}
h1,
h2,
h3,
h4 {
text-align: center;
}
.flex__grid {
display: flex;
justify-content: center;
transform-style: preserve-3d;
transform-origin: center;
perspective: 300px;
}
.btn {
position: relative;
z-index: 1;
color: hsl(300, 70%,20%);
background-color: transparent;
border: none;
margin: 1rem;
padding: 1rem 1.5rem;
outline: none;
font-variant: small-caps;
font-size: 1.25rem;
font-weight: 600;
letter-spacing: 1px;
&:after,
&:before {
content: '';
position: absolute;
z-index: -1;
}
&:after {
border-radius: 0.5rem;
width: 100%;
margin: auto;
background-color: hsl(302, 41%, 76%);
top: 0;
right: 0;
bottom: 0;
left: 0;
box-shadow: 0 0.25rem 0 0.05rem hsla(302, 41%, 50%, 1);
transform-origin: center;
transform: translate(0%, 0%);
transition: all 0.25s ease;
}
}
.btn--squash-stretch {
&:after {
animation: 4s infinite squash-stretch;
}
}
.btn--anticipation {
&:after {
animation: 0.5s ease-in-out infinite alternate anticipation;
}
}
.btn--staging {
&:after {
transform-origin: center;
transform: translate(0%, 0%);
animation:
0.25s ease-out forwards pose-2-pose,
0.75s linear 0.25s staging infinite ;
}
}
.btn--pose-2-pose {
&:after {
transform-origin: center;
transform: translate(0%, 0%);
animation:
0.75s ease-out infinite pose-2-pose alternate;
}
}
.btn--follow-through {
opacity: 0;
transform: translate(100%);
animation: 1s cubic-bezier(1, 0.02, 0.39, 1.52) infinite follow-through;
&:after {
transform: translate(25%);
animation: 1s cubic-bezier(.04,.14,.89,1.74) infinite follow-through;
}
}
.btn--slow-in,
.btn--slow-out,
.btn--slow-in-out {
opacity: 0;
transform: translateY(-100%) rotateX(90deg);
animation: 3s cubic-bezier(1, 0.02, 0.39, 1.52) infinite alternate slide-in;
}
.btn--slow-in {
animation: 3s cubic-bezier(1, 0.02, 0.39, 1.52) infinite forwards slide-in;
}
.btn--slow-out {
animation: 3s cubic-bezier(1, 0.02, 0.39, 1.52) infinite reverse slide-in;
}
.btn--arcs {
&,
&:after {
opacity: 0;
transform-origin: 0% 0%;
transform: translate(200%, -60%) rotate(70deg);
animation: 2s cubic-bezier(1, 0.02, 0.39, 1.5) infinite arcs;
}
}
.btn--secondary-action {
transform: translate(0);
animation: 1s infinite cubic-bezier(1, 0.02, 0.39, 1.52) secondary-action;
}
.btn--secondary-action--sibling {
transform: translate(0);
animation: 1s -0.22s infinite cubic-bezier(1, 1.02, 0.81, 1.39) secondary-action--sibling;
}
.btn--fast {
transform: scale(0, 0);
animation: 2s infinite ease reverse timing-fast;
}
.btn--slow {
transform: scale(1, 1);
animation: 2s infinite ease timing-slow;
}
.btn--exaggeration {
opacity: 0;
transform: translate(0, -100%) scale(1, 1);
animation: 2s cubic-bezier(1, 1.02, 0.81, 1.39) infinite exaggeration;
}
.btn--solid {
animation: 2s ease-in-out infinite alternate solid-drawing;
}
.btn--appeal {
&:after {
animation: 2s cubic-bezier(0.79, 0.14, 0.15, 0.86) infinite appeal;
}
}
@keyframes squash-stretch {
92% {
transform: scale(1, 1);
}
94% {
transform: scale(1.75, 0.5);
}
100% {
transform: scale(1, 1);
}
}
@keyframes staging {
0% {
transform: translate(-50%, -50%) rotate(0deg) scale(1, 1);
box-shadow: 1em 0em 0 0 hsla(302, 41%, 50%, 1);
}
100% {
transform: translate(-50%, -50%) rotate(360deg) scale(1, 1);
box-shadow: 1em 0 0 0 hsla(302, 41%, 50%, 1);
}
}
@keyframes pose-2-pose {
0% {
width: 100%;
}
25% {
width: 1em;
padding-top: 1em;
}
100% {
top: 50%;
right: calc(-50% - 2rem);
bottom: 50%;
left: 50%;
width: 1em;
padding-top: 1em;
margin: auto;
border-radius: 50%;
transform: translate(-50%, -50%);
}
}
@keyframes anticipation {
0% {
transform: rotate(2.5deg);
}
100% {
transform: rotate(-2.5deg);
}
}
@keyframes follow-through {
100% {
opacity: 1;
transform: translate(0%);
}
}
@keyframes slide-in {
25%, 75% {
opacity: 1;
transform: translateY(0%) rotateX(0deg);
}
}
@keyframes arcs {
50%, 100% {
opacity: 1;
transform-origin: 100% 50%;
transform: translate(0, 0) rotate(0deg);
}
}
@keyframes secondary-action {
0% {
transform: translate(0%);
}
60% {
transform: translate(28%);
}
100% {
transform: translate(0%);
}
}
@keyframes secondary-action--sibling {
70% {
transform: translate(0);
}
80% {
transform: translate(10%);
}
100% {
transform: translate(0%);
}
}
@keyframes timing-fast {
25%, 100% {
transform: scale(1, 1);
}
}
@keyframes timing-slow {
95%, 100% {
transform: scale(0, 0);
}
}
@keyframes exaggeration {
10% {
opacity: 1;
transform: translate(0, 90%) scale(2, 0.25);
}
15%, 100% {
opacity: 1;
transform: translate(0, 0) scale(1, 1);
}
}
@keyframes solid-drawing {
0% {
transform: rotateY(25deg);
}
100% {
transform: rotateY(-25deg);
}
}
@keyframes appeal {
15% {
box-shadow: -0.5rem 0.25rem 0 0.05rem hsla(302, 41%, 50%, 1);
}
20% {
box-shadow: 0.5rem 0.25rem 0 0.05rem hsla(302, 41%, 50%, 1);
}
25%, 100% {
box-shadow: 0rem 0.25rem 0 0.05rem hsla(302, 41%, 50%, 1);
}
}
Also see: Tab Triggers