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="demoWrapper">
<h2>MotionPath Infinite Followers</h2>
<svg viewBox="0 100 500 300" xmlns="http://www.w3.org/2000/svg" xmlns:bx="https://boxy-svg.com">
<defs>
<radialGradient gradientUnits="userSpaceOnUse" cx="159.2899" cy="67.8919" r="18.3749" id="gradient-0" gradientTransform="matrix(1.1831563, 1.14812218, -1.26716109, 1.30582767, 55.75520113, -206.24885464)">
<stop offset="0" style="stop-color: rgb(243, 93, 93);"></stop>
<stop offset="1" style="stop-color: rgb(171, 40, 40);"></stop>
</radialGradient>
<radialGradient gradientUnits="userSpaceOnUse" cx="220.3364" cy="62.2808" r="18.3749" id="gradient-1" gradientTransform="matrix(1.09012126, 1.09352086, -1.14662975, 1.14306465, 52.31376798, -251.23837502)">
<stop offset="0" style="stop-color: rgb(205, 145, 242);"></stop>
<stop offset="1" style="stop-color: rgb(158, 47, 195);"></stop>
</radialGradient>
<radialGradient gradientUnits="userSpaceOnUse" cx="314.8126" cy="69.5914" r="18.3749" id="gradient-2" gradientTransform="matrix(1.19585671, 1.09677242, -1.29765382, 1.4148858, 28.7714691, -383.56197674)">
<stop offset="0" style="stop-color: rgb(134, 248, 128);"></stop>
<stop offset="1" style="stop-color: rgb(94, 183, 90);"></stop>
</radialGradient>
<radialGradient gradientUnits="userSpaceOnUse" cx="389.343" cy="81.2703" r="18.3749" id="gradient-3" gradientTransform="matrix(1.09339778, 1.02009152, -0.97825622, 1.04855586, 43.73941401, -409.54784977)">
<stop offset="0" style="stop-color: rgb(178, 247, 255);"></stop>
<stop offset="1" style="stop-color: rgb(58, 156, 166);"></stop>
</radialGradient>
<filter id="drop-shadow-filter-2" color-interpolation-filters="sRGB" x="-50%" y="-50%" width="200%" height="200%" bx:preset="drop-shadow 1 2 2 2 0.4 rgba(0,0,0,1)">
<feGaussianBlur in="SourceAlpha" stdDeviation="2"></feGaussianBlur>
<feOffset dx="2" dy="2"></feOffset>
<feComponentTransfer result="offsetblur">
<feFuncA id="spread-ctrl" type="linear" slope="0.8"></feFuncA>
</feComponentTransfer>
<feFlood flood-color="rgba(0,0,0,1)"></feFlood>
<feComposite in2="offsetblur" operator="in"></feComposite>
<feMerge>
<feMergeNode></feMergeNode>
<feMergeNode in="SourceGraphic"></feMergeNode>
</feMerge>
</filter>
<linearGradient gradientUnits="userSpaceOnUse" x1="226.9601" y1="206.2308" x2="226.9601" y2="302.6589" id="gradient-4" gradientTransform="matrix(0.93081946, -0.36547936, 0.26818711, 0.7300394, -6.36124316, 135.9320854)">
<stop offset="0" style="stop-color: rgba(243, 243, 243, 1)"></stop>
<stop offset="1" style="stop-color: rgba(192, 192, 192, 1)"></stop>
</linearGradient>
<filter id="drop-shadow-filter-0" color-interpolation-filters="sRGB" x="-50%" y="-50%" width="200%" height="200%" bx:preset="drop-shadow 1 5 0 2 0.36 rgba(0,0,0,0.78)">
<feGaussianBlur in="SourceAlpha" stdDeviation="2"></feGaussianBlur>
<feOffset dx="5" dy="0"></feOffset>
<feComponentTransfer result="offsetblur">
<feFuncA id="feFuncA-1" type="linear" slope="0.72"></feFuncA>
</feComponentTransfer>
<feFlood flood-color="rgba(0,0,0,0.78)"></feFlood>
<feComposite in2="offsetblur" operator="in"></feComposite>
<feMerge>
<feMergeNode></feMergeNode>
<feMergeNode in="SourceGraphic"></feMergeNode>
</feMerge>
</filter>
<filter id="drop-shadow-filter-1" color-interpolation-filters="sRGB" x="-50%" y="-50%" width="200%" height="200%" bx:preset="drop-shadow 1 -5 0 2 0.36 rgba(0,0,0,0.61)">
<feGaussianBlur in="SourceAlpha" stdDeviation="2"></feGaussianBlur>
<feOffset dx="-5" dy="0"></feOffset>
<feComponentTransfer result="offsetblur">
<feFuncA id="feFuncA-1" type="linear" slope="0.72"></feFuncA>
</feComponentTransfer>
<feFlood flood-color="rgba(0,0,0,0.61)"></feFlood>
<feComposite in2="offsetblur" operator="in"></feComposite>
<feMerge>
<feMergeNode></feMergeNode>
<feMergeNode in="SourceGraphic"></feMergeNode>
</feMerge>
</filter>
</defs>
<path style="fill: none; stroke-width: 4px; stroke: rgb(220, 220, 220);" d="M 45.059 201.9555 C 45.059 201.9555 135.906 309.9383 245.4774 201.5695 C 355.0488 93.2007 445.4774 201.5695 445.4774 201.5695" class="path"></path>
<path style="fill: none; stroke-width: 4px; stroke: url(#gradient-4);" d="M 44.7888 203.7412 C 44.7888 203.7412 135.6358 311.724 245.2072 203.3552 C 354.7786 94.9864 445.2072 203.3552 445.2072 203.3552" class="pathShadow"></path>
<g transform="matrix(1, 0, 0, 1, 24.57774544, -4.09961891)" class="circles">
<title>group</title>
<ellipse style="stroke-width: 0px; fill: url(#gradient-0); filter: url(#drop-shadow-filter-2);" cx="166.4641" cy="74.4483" rx="18.3749" ry="18.3749"></ellipse>
<ellipse style="stroke-width: 0px; fill: url(#gradient-1); filter: url(#drop-shadow-filter-2);" cx="228.2173" cy="69.547" rx="18.3749" ry="18.3749"></ellipse>
<ellipse style="stroke-width: 0px; fill: url(#gradient-2); filter: url(#drop-shadow-filter-2);" cx="324.48" cy="69.4432" rx="18.3749" ry="18.3749"></ellipse>
<ellipse style="stroke-width: 0px; fill: url(#gradient-3); filter: url(#drop-shadow-filter-2);" cx="398.6265" cy="81.6251" rx="18.3749" ry="18.3749"></ellipse>
</g>
<g transform="matrix(1, 0, 0, 1, 4e-8, 2.24961448)" class="tunnels">
<title>tunnels</title>
<path d="M 47.82 150.6681 L 101.7282 200.3381 C 93.9558 187.5973 46.6723 240.3772 53.9083 252.2385 L 0 202.5685 L 47.82 150.6681 Z" style="filter: url(#drop-shadow-filter-0); fill: rgb(255, 255, 255); transform-origin: -64.2032px 247.169px;"></path>
<path d="M 418.3812 170.6905 L 492.2043 170.6905 L 492.2043 238.6099 L 418.3812 238.6099 C 426.7681 246.3143 430.1181 181.4724 418.3812 170.6905 Z" style="filter: url(#drop-shadow-filter-1); fill: rgb(255, 255, 255); transform-origin: 455.293px 204.967px;" transform="matrix(0.73313077, 0.6800877, -0.6800877, 0.73313077, 0.00001128, -0.00000665)"></path>
</g>
</svg>
</div>
body, html {
height:90vh;
}
body {
margin:0;
}
.spacer {
height:100vh;
display:flex;
align-items:center;
justify-content:center;
color:#efefef;
font-family:sans-serif;
font-size:10vw;
}
.demoWrapper {
opacity:0;
width:100%;
min-width:375px;
display:flex;
align-items:center;
justify-content:center;
flex-direction:column;
}
.demo {
border:1px solid #333;
}
h2 {
color:#333;
font-size:clamp(18px, 3vw, 30px);
font-family:Arial, sans-serif;
}
gsap.set(".demoWrapper", { opacity:1})
const circles = gsap.utils.toArray(".circles ellipse")
const tl = gsap.timeline({repeat:20})
// *** secret sauce ***
// *** evenly disperse between 0 and 1 for each iteration ***
for (let i = 0; i < 25; i++){
console.log(i, i/25)
}
circles.forEach((circle, i) => {
let start = i/circles.length // secret sauce for circles
console.log(start)
tl.to(circle, {
motionPath: {
path: ".path",
align: ".path",
alignOrigin: [0.5, 0.5],
start:start,
end:start + 1
}, ease:"none", duration:3
}, 0)
})
//GSDevTools.create({animation:tl})
gsap.config({trialWarn: false})
Also see: Tab Triggers