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 id="app"></div>
body {
color: white;
}
svg {
max-width: 100%;
}
.vector {
position: absolute;
bottom: 0;
}
section {
min-height: 100vh;
position: relative;
margin: 0;
background: #000;
&:nth-child(2) {
background: #121212;
}
&:last-child {
background: #333;
}
}
h1 {
padding: 5rem;
text-align: center;
color: coral;
}
const { useRef, useLayoutEffect } = React;
gsap.registerPlugin(ScrollTrigger);
const Ball = () => {
const tl = useRef();
useLayoutEffect(() => {
const getVectorPaths = document.querySelectorAll(".vector path");
getVectorPaths.forEach((el, index) => {
el.style.strokeDasharray = el.getTotalLength();
});
tl.current = gsap
.timeline()
.from(".cover-vector-1 path", {
strokeDashoffset:
document.querySelector(".cover-vector-1 path").getTotalLength() + 4
})
.to(".cover-vector-1", {
opacity: 0,
ease: "none"
})
.from(".cover-vector-2 path", {
strokeDashoffset:
document.querySelector(".cover-vector-2 path").getTotalLength() + 4
})
.to(".cover-vector-2 path", {
opacity: 0,
ease: "none"
})
.from(".cover-vector-3 path", {
strokeDashoffset:
document.querySelector(".cover-vector-3 path").getTotalLength() + 4
});
ScrollTrigger.create({
animation: tl.current,
trigger: ".section-1",
start: "top top",
end: "top top-=2500",
pin: ".section-1",
scrub: 2,
// onLeave: function (self) {
// self.scroll(self.start);
// self.disable();
// self.animation.progress(1);
// }
});
gsap.from(".section-2 h1", {
y: 500,
scale: 5,
scrollTrigger: {
trigger: ".section-2",
scrub: true,
start: "top center",
end: "top top",
markers: true
}
});
}, []);
return (
<>
<h1>Scroll to draw</h1>
<section className="section-1">
<div className={`vector cover-vector-1`}>
<svg
className="es-cover-vector"
width="1920"
height="529"
viewBox="0 0 1920 529"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M1919.5 393.483C1898 379.983 1730 370.983 1665 436.483C1613 488.883 1534.33 476.317 1501.5 463.483C1455.67 440.983 1362.7 395.483 1357.5 393.483C1335 385.983 1293.5 343.983 1285 336.983C1271 329.483 1176.5 245.483 1159 229.983C1145 217.583 1129.5 220.15 1123.5 222.983L1097 225.483C1077.83 226.65 1038.5 229.183 1034.5 229.983C1009 233.983 1009 239.483 1006.5 243.483C988.5 273.983 980.5 307.983 982 308.983C1016.5 298.983 1085.5 313.983 1090 314.983C1126 316.483 1109.5 311.983 1106.5 311.483C1091.3 309.483 1086.83 300.317 1086.5 295.983C1085.83 295.317 1083.9 293.383 1081.5 290.983C1072 280.983 1076 270.983 1075.5 271.483C1069.5 287.483 1052.5 283.983 1048 282.483C1033 267.483 1033.5 253.983 1034.5 253.483C1047.5 264.483 1039.5 287.483 1036.5 294.983C1032.9 308.583 1022 309.983 1017 308.983C1007.67 308.483 987.6 308.083 982 310.483C963.2 321.283 970.167 344.317 976 354.483L985.5 389.483C977.833 390.817 962.1 393.483 960.5 393.483C949 394.483 949.5 398.483 949 399.483C947.5 403.483 956.5 414.983 956 415.483C936 433.483 921.5 414.983 922.5 413.983C930.1 401.183 920.667 398.983 915 399.483L878.5 398.483C876.5 387.65 872.5 365.483 872.5 363.483C871.7 349.483 876.5 347.65 879 348.483C880.5 349.15 884.4 350.883 888 352.483C906 362.983 909.5 352.983 910 351.983C912 346.483 903.5 332.983 902.5 331.483C894 321.483 892 324.483 890.5 324.983C875 334.483 873.5 329.483 872.5 328.983C868.1 325.383 866.667 306.15 866.5 296.983L869.5 295.983C876.667 294.817 891.9 292.283 895.5 291.483C917 287.983 918 293.983 917.5 294.983C906.5 321.983 934 314.483 936.5 313.483C962 303.483 948 299.983 944.5 296.983C935.7 284.983 959.5 286.65 972.5 288.983C972.5 289.65 972.5 292.483 972.5 298.483C971 313.983 989 313.483 994 314.483C1016.5 316.483 1006.5 341.983 1005.5 344.983C1001.5 353.983 992.5 349.483 989 348.983C973.5 344.483 977 349.983 977.5 351.483C986.7 365.083 1016.67 367.817 1030.5 367.483C1045.33 367.65 1075.8 368.183 1079 368.983C1152 385.483 1104.5 412.983 1099.5 415.483C1058 429.983 1052 414.483 1051 412.983C1041.5 391.483 1045.5 388.483 1048 386.983C1058.5 380.983 1055.5 373.483 1053.5 373.483C1018.3 368.283 1016.17 371.317 1019.5 373.483L1037.5 388.483C1047.5 390.65 1068.3 394.983 1071.5 394.983C1096 396.483 1089.5 380.983 1088.5 379.983C1066 366.483 1062.5 377.483 1062 379.983C1063 394.483 1088.5 390.983 1093 390.983C1131.5 395.983 1096.5 408.483 1093 408.983C1083.8 408.183 1086.17 400.317 1088.5 396.483L1103.5 388.483L1107 384.483L1121 389.983C1136.17 402.65 1168.1 429.283 1174.5 434.483C1212 465.983 1234 468.483 1239 467.983C1281.5 467.483 1292.5 474.983 1298.5 476.983C1427.5 536.983 1298 506.483 1282.5 506.483C1180.5 486.983 1040 504.983 1032.5 506.483C943 532.983 883.5 526.983 879.5 525.983C812 515.483 813.5 456.983 813 454.983C810.5 421.483 832.5 435.983 834 436.983C852 444.983 851.167 433.65 848.5 426.983C847 423.983 843.5 417.483 841.5 415.483C835 405.983 831.5 408.483 830 409.483C816.8 419.083 811.167 413.483 810 409.483C808.667 404.317 806 393.283 806 390.483C806.8 380.483 798.667 379.65 794.5 380.483C790.667 380.983 782.4 382.083 780 382.483C763.5 383.983 774.5 366.483 775 363.483C772.5 350.983 746 359.983 744 360.983C734.5 365.483 744 371.983 746 373.983C753.2 381.583 745.667 384.817 741 385.483L711.5 387.983C711.5 393.65 711.5 405.583 711.5 407.983C709 419.983 715.5 418.983 717.5 417.983C721.9 413.583 726.667 414.817 728.5 415.983C731.667 419.317 738.4 426.583 740 428.983C749.5 452.983 725 445.983 721.5 444.983C711.1 439.783 710.833 445.817 712 449.483L722.5 493.483C724.667 493.317 731.8 492.883 743 492.483C759 491.483 755.5 488.483 755 485.983C750.5 469.483 757.5 466.983 766.5 462.483C789.5 447.983 779.5 481.483 779 484.483C776 502.483 791 493.983 801.5 489.483C814.7 482.683 804.667 483.317 798 484.483C787.5 488.983 765.1 497.983 759.5 497.983C694 504.983 635 496.983 612 492.983C458.4 458.983 617.333 345.817 716 293.483C752.5 274.65 834.7 234.183 871.5 222.983C917.5 208.983 963.5 222.983 920.5 242.483C886.1 258.083 869.5 250.983 865.5 245.483C849.5 234.65 814.8 211.683 804 206.483C794 200.483 770.5 202.65 760 204.483C754.833 204.65 743.3 205.083 738.5 205.483C728.851 205.883 726.146 200.317 726 197.483C726 187.483 726 166.683 726 163.483C725 154.483 730 143.983 732 141.983C738.8 135.183 734.833 123.15 732 117.983C732.167 113.983 732.4 104.983 732 100.983C727.5 78.9834 717 84.9834 716 86.4834C717 101.983 742 99.4834 751 98.4834C772 92.4834 759.5 86.9834 758 86.4834C739.5 88.4834 744.5 117.483 744 118.983C738.5 133.483 741.5 138.483 743 140.983C757 152.983 753 190.483 752.5 194.483C754 214.983 734 210.483 727 209.983C698.5 209.983 700 198.983 698.5 194.483C694.5 159.983 681 137.483 677.5 131.983C653 82.9834 667 54.4834 668.5 49.9834C708 -21.0166 768.5 7.4834 772.5 8.4834C858.5 55.4834 808 127.983 807 128.983C783.5 148.983 783.5 186.983 783.5 187.983C783 219.983 751 213.483 747.5 213.983C704 210.483 707.5 219.483 708 220.983C713.5 235.483 764 231.483 764 228.983C757 215.483 726 222.483 723 222.983C693.5 231.983 724 240.483 738.5 242.483C776.5 244.983 762.5 237.983 761.5 236.983C748.5 232.483 727 235.983 725 235.983C701 240.483 726.5 247.483 729 247.983C753.8 250.383 750 254.317 745 255.983C729 260.483 695.1 269.683 687.5 270.483C574.5 279.983 505.5 268.483 483.5 263.983C352.3 229.983 237.167 252.817 196 268.483C137 289.489 15.2 345.9 0 403.5"
stroke="url(#paint0_linear_1420_110)"
strokeWidth="2.75"
strokeMiterlimit="2.61"
strokeLinecap="round"
/>
<defs>
<linearGradient
id="paint0_linear_1420_110"
x1="1892.71"
y1="498.194"
x2="1063.15"
y2="994.413"
gradientUnits="userSpaceOnUse"
>
<stop offset="0.197816" stopColor="#0066CC" />
<stop offset="0.714684" stopColor="#EB3300" />
<stop offset="1" stopColor="#EB8D00" />
</linearGradient>
</defs>
</svg>
</div>
<div className={`vector cover-vector-2`}>
<svg
className="es-cover-vector"
width="1920"
height="444"
viewBox="0 0 1920 444"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M-6 381.5C20.7134 398.953 131.049 401.677 150.639 395.001C181.162 384.6 274.548 370.038 403.912 395.001C533.276 419.965 559.123 366.398 555.876 336.494H532.497L559.772 297.489L588.996 242.882L680.564 293.588L653.288 303.339C676.667 337.144 741.35 393.441 813.045 348.195C836.424 334.153 882.533 283.837 902.665 260.434L912.406 297.489L914.354 303.339L955.268 301.389C941.63 323.492 918.255 357.607 905.391 370.884C893.1 383.569 808.598 446.613 745.222 441.231C687.502 436.33 548.083 400.851 555.876 213.627C562.11 63.8479 681.863 30.3036 740.96 32.2538L744.856 3L820.838 73.2091L748.753 143.418V110.264C727.322 113.514 685.303 127.166 668.875 143.418C655.237 159.02 647.444 166.821 631.858 244.831C630.299 247.952 620.818 227.929 616.272 217.528L606.53 213.627C595.49 215.577 573.41 220.258 573.41 223.378C573.41 227.279 585.822 160.225 600.686 137.567C605.808 129.76 684.46 12.7513 830.58 143.418C849.283 159.02 976.049 302.039 1037.09 371.598L1017.61 395.001L1126.71 406.702V307.239L1103.34 324.792L955.268 157.07L918.251 114.164C894.872 86.2107 839.931 32.2538 807.201 40.0548C807.201 42.005 914.355 112.214 961.113 213.627C967.347 222.988 1023.46 317.641 1050.73 363.797C1063.72 385.899 1099.44 431.275 1138.4 435.956C1144.25 435.956 1233.87 465.21 1313.75 395.001C1323.49 385.249 1372.19 352.094 1393.62 266.283C1399.86 264.723 1420.9 265.633 1430.64 266.283L1364.4 190.223L1274.78 252.631H1313.75C1307.25 280.584 1302.93 337.44 1245.7 350.144C1221.89 352.816 1178.02 352.094 1148.15 350.144L1173.47 379.398L1148.15 414.502C1177.5 419.703 1248.61 421.523 1298.16 387.199C1313.75 371.598 1378.04 307.238 1378.04 238.98C1378.04 227.278 1389.73 112.213 1317.64 73.2082C1304.01 59.5565 1148.14 -2.85159 1054.63 82.9595C1053.07 84.5197 1034.5 69.3077 1025.41 61.5067L1017.61 184.373L1126.71 172.671L1099.44 145.368C1139.05 110.263 1234.26 70.0878 1298.16 190.223C1304.01 198.024 1311.8 211.676 1325.44 178.522C1333.23 166.82 1348.82 157.069 1401.42 201.925C1415.06 207.776 1493.09 307.069 1543.74 281.716C1643.03 254.557 1598.95 303.307 1706.25 337.37C1759.23 359.852 1915.84 301.255 1933.5 320.5"
stroke="url(#paint0_linear_1455_168)"
strokeWidth="2.75"
strokeMiterlimit="2.61"
strokeLinecap="round"
/>
<defs>
<linearGradient
id="paint0_linear_1455_168"
x1="82.6538"
y1="103.716"
x2="673.742"
y2="1065.33"
gradientUnits="userSpaceOnUse"
>
<stop offset="0.197816" stopColor="#0066CC" />
<stop offset="0.551298" stopColor="#EB8D00" />
<stop offset="1" stopColor="#EB3300" />
</linearGradient>
</defs>
</svg>
</div>
<div className={`vector cover-vector-3`}>
<svg
className="es-cover-vector"
width="1920"
height="590"
viewBox="0 0 1920 590"
fill="none"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M-21 389.449C-4.68035 389.449 602.822 389.449 789.034 389.449L863.309 406.711V274.894C863.832 267.222 872.62 252.192 903.585 253.447C934.551 254.702 1023.54 253.97 1064.17 253.447L1064.69 247.17H1039.58C1040.98 235.139 1041.15 211.6 1036.44 194.338C1031.64 176.711 1022.32 151.445 988.322 148.829C975.419 147.957 952.23 150.397 940.2 174.983C926.895 202.174 929.738 228.807 931.308 241.416C930.471 241.414 908.99 241.415 898.354 241.416V187.536C905.677 146.214 927.579 132.355 954.846 122.673C1010.81 102.801 1063.12 136.8 1067.3 174.983L1072.01 253.447C1082.12 252.751 1102.35 256.903 1102.35 279.082C1102.35 301.261 1102.35 371.668 1102.35 404.1C1099.21 419.618 1085.4 450.655 1055.27 450.655C1025.15 450.655 1005.06 450.655 998.783 450.655L997.214 397.823H1006.63L1000.35 357.022C1005.93 354.755 1016.04 343.631 1011.86 317.267C1004.01 307.852 992.506 294.251 968.968 313.606C964.261 321.975 958.507 340.806 976.814 357.022C974.304 365.81 967.748 386.489 964.784 395.73H991.983V450.655H907.77L876.386 419.792L874.293 429.731L902.016 456.409H1137.4C1156.23 441.413 1193.36 396.672 1191.27 337.668C1189.18 278.663 1185.17 151.623 1183.43 95.4783C1117.52 56.5955 946.163 1.3226 787.988 91.2936C786.732 116.397 782.931 290.414 781.188 374.284H743.527V63.57C815.013 18.412 1011.65 -45.96 1226.32 57.8161C1226.32 143.602 1229.46 298.611 1231.02 365.391C1228.41 388.93 1213.97 442.494 1177.15 468.44C1140.32 467.603 1135.83 467.185 1135.83 467.393L1126.93 468.963L997.214 546.38C992.332 549.344 977.233 552.657 955.892 542.195C929.215 529.118 836.11 488.84 795.834 399.915C761.521 399.915 750.153 399.915 748.758 399.915C766.019 434.613 824.811 516.25 921.892 565.211C946.581 576.928 968.794 585.088 976.814 587.703C984.835 589.447 1008.2 589.168 1037.49 574.103C1074.1 555.272 1163.55 483.086 1170.35 477.855C1175.79 473.67 1191.1 473.322 1198.07 473.67H1941.5"
stroke="url(#paint0_linear_1424_126)"
strokeWidth="2.75"
strokeMiterlimit="2.61"
strokeLinecap="round"
/>
<defs>
<linearGradient
id="paint0_linear_1424_126"
x1="1664"
y1="509.998"
x2="746.273"
y2="918.575"
gradientUnits="userSpaceOnUse"
>
<stop offset="0.262434" stopColor="#0066CC" />
<stop offset="0.602083" stopColor="#EB8D00" />
<stop offset="1" stopColor="#EB3300" />
</linearGradient>
</defs>
</svg>
</div>
</section>
<section className="section-2">
<h1>2</h1>
</section>
<section className="section-3">
<h1>3</h1>
</section>
</>
);
};
ReactDOM.render(<Ball />, document.getElementById("app"));
Also see: Tab Triggers