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.
<svg viewBox="0 0 1400 1080" fill="none" xmlns="http://www.w3.org/2000/svg">
<path id="paperPlaneRoute" d="M563.558,526.618 C638.854,410.19 787.84,243.065 916.53,334.949 1041.712,424.328 858.791,877.927 743.926,856.655 642.241,838.669 699.637,688.664 700,540" stroke="white" stroke-width="3" style="stroke-dashoffset: 0.001px; stroke-dasharray: 0px, 999999px;"/>
<g id="rectSent" clip-path="url(#clipPath)">
<g id="rectSentItems">
<rect id="sentBase" x="460" y="468.5" width="480" height="143" rx="23" fill="white"/>
<text id="txtSent" fill="#4F67ED" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="82" font-weight="bold" letter-spacing="0.025em"><tspan x="637.487" y="568.027">Sent!</tspan></text>
</g>
</g>
<g id="base">
<g filter="url(#flShadow)"><rect id="btnBase" x="418.117" y="460.55" width="563.765" height="158.899" rx="27" fill="#F1F3FF" /></g>
<text id="txtSend" fill="#291D89" xml:space="preserve" style="white-space: pre" font-family="Roboto" font-size="82" font-weight="bold" letter-spacing="0.06em"><tspan x="679.379" y="568.027">Send</tspan></text>
<g id="paperPlane" style="transform-origin: 0px 0px 0px;" data-svg-origin="563.55859375 527.734375" transform="matrix(0.8396,0.5432,-0.5432,0.8396,377.09924,-222.6639)">
<path id="paperPlanePath" d="M560.611 481.384C562.003 479.263 565.113 479.263 566.505 481.384L607.063 543.177C615.657 556.272 607.507 573.375 592.766 575.676L566.422 557.462V510.018C566.422 508.436 565.14 507.154 563.558 507.154C561.976 507.154 560.693 508.436 560.693 510.018V557.462L534.349 575.676C519.609 573.375 511.459 556.272 520.053 543.177L560.611 481.384Z" fill="#4F67EB"/>
</g>
</g>
<circle id="cBottom" cx="700" cy="540" r="97.516" fill="#C23F3F" class="hidden"/>
<circle id="cTop" cx="700" cy="502.365" r="107.898" fill="#C23F3F" class="hidden"/>
<circle id="cCenter" cx="700" cy="540" r="123" fill="#A74C4C" class="hidden" />
<circle id="cEnd" cx="495" cy="540" r="98" fill="#F1F3FF" class="hidden"/>
<path id="tickMark" fill-rule="evenodd" clip-rule="evenodd" d="M597.3 489.026C595.179 487.257 592.026 487.541 590.257 489.662L550.954 536.768L534.647 522.965C532.539 521.181 529.384 521.444 527.6 523.551L519.096 533.598C517.312 535.706 517.575 538.861 519.682 540.645L538.606 556.662C538.893 557.162 539.272 557.621 539.74 558.012L549.847 566.445C551.967 568.214 555.12 567.929 556.889 565.809L608.042 504.501C609.811 502.38 609.527 499.227 607.406 497.458L597.3 489.026Z" fill="#4E67E8" class="hidden"/>
<defs>
<clipPath id="clipPath">
<rect id="mask1" x="700" y="450" width="520" height="180" fill="white" id="clipRect"/>
</clipPath>
<filter id="flShadow" x="0" y="0" width="1000" height="1000" filterUnits="userSpaceOnUse" color-interpolation-filters="sRGB">
<feFlood flood-opacity="0" result="BackgroundImageFix"/>
<feColorMatrix in="SourceAlpha" type="matrix" values="0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 127 0"/>
<feOffset dx="4" dy="4"/>
<feGaussianBlur stdDeviation="3.5"/>
<feColorMatrix type="matrix" values="0 0 0 0 0.5125 0 0 0 0 0.420677 0 0 0 0 0.420677 0 0 0 0.25 0"/>
<feBlend mode="normal" in2="BackgroundImageFix" result="effect1_dropShadow"/>
<feBlend mode="normal" in="SourceGraphic" in2="effect1_dropShadow" result="shape"/>
</filter>
</defs>
</svg>
@import url("https://fonts.googleapis.com/css2?family=Roboto:wght@700&display=swap");
body {
margin: 0;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
font-family: "Roboto", sans-serif;
font-weight: bold;
background-color: #291d89;
}
svg {
width: 100%;
height: 100vh;
}
.hidden {
visibility: hidden;
}
#base {
cursor: pointer;
}
gsap.registerPlugin(MotionPathPlugin);
MorphSVGPlugin.convertToPath("circle, rect");
gsap.set("#paperPlaneRoute", { drawSVG: "0% 0%" });
gsap.set("#rectSentItems", { x: "-=240" });
const tl = gsap.timeline();
let ranOnce = false;
function onBtnUp() {
if (ranOnce) {
tl.restart();
return;
}
ranOnce = true;
tl.to("#base", { duration: 0.2, scale: 1, transformOrigin: "50% 50%" });
tl.to(
"#btnBase",
{ duration: 0.77, morphSVG: "#cBottom", ease: "power1.inOut" },
"start"
);
tl.to("#btnBase", { duration: 0.23, morphSVG: "#cTop", ease: "power1.inOut" });
tl.to("#btnBase", {
duration: 0.2,
morphSVG: "#cCenter",
ease: "power1.inOut"
});
tl.to(
"#btnBase",
{ duration: 0.5, morphSVG: "#cEnd", ease: "power1.inOut" },
"revealStart"
);
tl.to("#rectSentItems", { x: "0", duration: 0.5 }, "revealStart");
tl.to(
"#mask1",
{ x: "-=260", duration: 0.5, ease: "power1.inOut" },
"revealStart"
);
tl.to(
"#paperPlane",
{ x: "-=205", duration: 0.5, ease: "power1.inOut" },
"revealStart"
);
tl.to(
"#paperPlanePath",
{ duration: 0.43, morphSVG: "#tickMark" },
"start+=0.77"
);
tl.to(
"#txtSend",
{ duration: 0.6, scale: 0, transformOrigin: "50% 50%" },
"start"
);
tl.to(
"#paperPlaneRoute",
{ drawSVG: "80% 100%", duration: 0.7, ease: "power1.inOut" },
"start+=0.3"
);
tl.to(
"#paperPlaneRoute",
{ drawSVG: "100% 100%", duration: 0.2, ease: "power1.inOut" },
"start+=1"
);
tl.to(
"#paperPlane",
{
duration: 1,
ease: "power1.inOut",
immediateRender: true,
motionPath: {
path: "#paperPlaneRoute",
align: "#paperPlaneRoute",
alignOrigin: [0.5, 0.5],
autoRotate: 90
}
},
"start"
);
tl.to(
"#paperPlanePath",
{ duration: 0.15, attr: { fill: "#ffffff" } },
"start"
);
tl.to(
"#paperPlanePath",
{ duration: 0.15, attr: { fill: "#4E67E8" } },
"start+=0.77"
);
}
function onBtnDown() {
gsap.timeline({ defaults: { clearProps: true } });
gsap.to("#base", { duration: 0.1, scale: 0.9, transformOrigin: "50% 50%" });
}
const btn = document.getElementById("base");
btn.addEventListener("mousedown", onBtnDown);
btn.addEventListener("mouseup", onBtnUp);
Also see: Tab Triggers