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.
.path-cont
svg(preserveAspectRatio="none" viewbox='0 0 100 100' xmlns='http://www.w3.org/2000/svg').svgpath
path(fill='none' stroke-dasharray="5,3" stroke='#0070f3' d='M51,0 L61,7 L69,12 L74,18 L72,25 L62,29 L45,32 L29,32 L13,26 L20,19 L37,15 L56,15 L68,17 L80,24 L82 31 L76,37 L67,43 L57,49 L44,55 L35,60 L26,66 L25,70 L30,75 L36,81 L46,86 L55,91 L65,96 L72,99')
.obj
.big-thing
h1 Scroll Onwards
p
strong Sadly no love in firefox and safari yet for animation timeline, have to wait on such implementations.
p
a(href="https://codepen.io/ghaste/pen/PoVWgZp" target="_blank") SVG path
| based offset-path does not support responsive design, which is another draw-back.
p You can use a
strong polygon path
|, which is responsive, but you will then have to create that visible path yourself (intentionally terrible job here). It will not be a smooth path as shown here.
p I found that the
a(href="https://bennettfeely.com/clippy/" target="_blank") Clippy
| - clip-path generator
| can be used for generating the polygon.
p Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed tristique sit amet erat vitae ultrices. Proin ultrices, velit a gravida convallis, orci neque aliquet quam, ac aliquam odio dolor sit amet est. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Sed faucibus magna ac lorem pellentesque tincidunt. Cras eu sem sit amet orci tincidunt convallis. Aliquam faucibus blandit porttitor. Donec efficitur in quam vitae blandit. Sed sed dui mi. Integer euismod enim quis gravida pretium. Curabitur sed lacus nec nulla tristique tincidunt ut id ex. Aenean dignissim lorem sit amet neque vulputate, vel consequat magna mattis. Integer et volutpat orci. Sed vehicula, nisl vel dignissim feugiat, eros risus condimentum neque, et lacinia est purus sed sem. Mauris sagittis ultricies dolor.
p Sed nec neque tempus, vulputate ligula sit amet, euismod orci. Nunc cursus quam a pharetra sagittis. Donec quis diam vel quam feugiat laoreet. Ut lobortis semper turpis, vitae fermentum tortor scelerisque pharetra. Nullam aliquet ipsum a condimentum bibendum. Integer ac purus mi. Nam rutrum orci vitae feugiat luctus. Quisque sodales, nisi eu accumsan sodales, nisl metus semper nisl, non fringilla turpis quam a tortor. Aenean posuere nisl vitae felis fermentum congue.
p Integer imperdiet ligula tristique, tincidunt augue in, congue elit. Etiam elementum nec urna nec tincidunt. Fusce arcu nisl, rhoncus non dignissim vel, venenatis at augue. In auctor eu nisl et imperdiet. Duis imperdiet vehicula est, ac convallis urna hendrerit et. Sed pulvinar nunc eu enim placerat, eget lobortis libero laoreet. Donec et mollis metus. Nunc leo magna, dignissim eu neque hendrerit, commodo varius lacus. Morbi pretium, augue vel commodo convallis, felis nisi tincidunt mauris, sed scelerisque massa quam ut ipsum. Sed pellentesque nisl ut dapibus condimentum. Quisque nec dapibus ante. Mauris ac accumsan augue. Donec tincidunt est imperdiet augue ultricies finibus. Vivamus volutpat egestas tellus a malesuada.
p Duis at velit bibendum ligula accumsan tempor vel ac justo. Ut rutrum lectus vel tristique maximus. Cras vitae nibh sit amet justo mattis porta in sit amet tellus. Aenean vitae nunc elementum, auctor arcu in, hendrerit ligula. Pellentesque nec vehicula sapien. Suspendisse ac metus consectetur, gravida ante quis, suscipit mauris. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Aliquam tincidunt venenatis tristique. Pellentesque tristique lectus nunc, ac gravida ante scelerisque nec. Nullam a libero sit amet ipsum malesuada porttitor.
.path-cont {
position: fixed;
width: 20vw;
height: 100vh;
top: 0;
left: 0;
pointer-events: none;
color: #FBF7F490;
z-index: -10;
}
.svgpath {
width: 100%;
height: 100%;
position: absolute;
inset: 0;
path {
stroke: #FBF7F430;
}
}
.obj {
position: absolute;
offset-path: polygon(51% 0%, 61% 7%, 69% 12%, 74% 18%, 72% 25%, 62% 29%, 45% 32%, 29% 32%, 13% 26%, 20% 19%, 37% 15%, 56% 15%, 68% 17%, 80% 24%, 82% 31%, 76% 37%, 67% 43%, 57% 49%, 44% 55%, 35% 60%, 26% 66%, 25% 70%, 30% 75%, 36% 81%, 46% 86%, 55% 91%, 65% 96%, 72% 99%);
animation: followpath linear;
animation-timeline: scroll();
}
@keyframes followpath {
from {
offset-distance: 2%;
}
//unlike a path, a polygon is a closed, so you will have to test this out, on where to end your offset.
to {
offset-distance: 60%;
}
}
@import url('https://fonts.googleapis.com/css2?family=Architects+Daughter&family=Roboto:wght@100;400&display=swap');
body {
background-color: #1f2020;
color: #FBF7F4;
font-family: Roboto, sans-serif;
font-weight: 100;
}
h1 {
font-family: 'Architects Daughter', cursive;
font-size: clamp(2rem, 8vw + 1rem, 10rem);
line-height: 1;
margin: 0;
background-image:
linear-gradient(#ff6090, #E23636);
background-clip: text;
-webkit-background-clip: text;
color: transparent;
}
p {
line-height: 1.5;
}
.big-thing {
width: min(50ch, 100% - 2rem);
margin: 0 auto;
}
.obj {
--bg: white;
--brd: #ff6090;
width: 3vmin;
height: 1.5vmin;
border-top-right-radius: 30% 20%;
border-bottom-right-radius: 30% 20%;
border-top-left-radius: 30% 15%;
border-bottom-left-radius: 30% 15%;
border: 1px solid var(--brd);
border-width: .5vmin 2.5vmin .5vmin .8vmin;
box-shadow: 0 0 0 .08em #000;
background-color: var(--bg);
}
.path-cont:before {
content: '0%';
position: absolute;
left: 40%;
}
.path-cont:after {
content: '100%';
position: absolute;
right: 0;
bottom: 0;
}
a {
color: #ff6090;
text-decoration-color: #ffafaf90;
}
Also see: Tab Triggers