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.
<header class="page-header">
<h1>Scroll down to trigger the animation</h1>
</header>
<section id="scroll-section">
<svg class="line-svg" role="presentational" preserveAspectRatio="xMidYMin slice" width="100%" fill="none" viewBox="-480 0 2300 2241">
<path class="anim-overview-stroke" stroke="#C7DBF4" stroke-width="200" d="M-841 100H584c124 0 225 101 225 225v0c0 124-101 225-225 225h-95a281 281 0 00-281 281v0c0 155 125 281 281 281h442c167 0 304 136 304 304v0c0 168-137 304-304 304H795a439 439 0 00-439 439v82" opacity=".45"></path>
</svg>
<div class="container">
<h2>Section Heading</h2>
<div class="layout-container">
<div class="box box-1">
<h3>Box Heading</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Tellus mauris a diam maecenas sed enim ut sem. Sapien pellentesque habitant morbi tristique senectus et netus et. Eget arcu dictum varius duis at. Orci ac auctor augue mauris augue neque gravida.</p>
<a href="#" class="btn">Find out more</a>
</div>
<img class="image-1" src="https://assets.codepen.io/732/matthew-deltoro-LdFvvpjnB2A-unsplash-800.jpg" width="400" height="400" />
<div class="box box-2">
<h3>Box Heading</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Tellus mauris a diam maecenas sed enim ut sem. Sapien pellentesque habitant morbi tristique senectus et netus et. Eget arcu dictum varius duis at. Orci ac auctor augue mauris augue neque gravida.</p>
<a href="#" class="btn">Find out more</a>
</div>
<img class="image-2" src="https://assets.codepen.io/732/viviana-rishe-6fNZ7QtXiCs-unsplash-800.jpg" width="400" height="600"/>
<div class="box box-3">
<h3>Box Heading</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Tellus mauris a diam maecenas sed enim ut sem. Sapien pellentesque habitant morbi tristique senectus et netus et. Eget arcu dictum varius duis at. Orci ac auctor augue mauris augue neque gravida.</p>
<a href="#" class="btn">Find out more</a>
</div>
<img src="https://assets.codepen.io/732/colton-sturgeon-FiCPutl_aog-unsplash-800.jpg" class="image-3" width="400" height="400"/>
<div class="box box-4">
<h3>Box Heading</h3>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Tellus mauris a diam maecenas sed enim ut sem. Sapien pellentesque habitant morbi tristique senectus et netus et. Eget arcu dictum varius duis at. Orci ac auctor augue mauris augue neque gravida.</p>
<a href="#" class="btn">Find out more</a>
</div>
</div>
</div>
</section>
<section class="bottom"></section>
html {
background-color: rgb(32, 91, 173);
}
body {
font-family: 'Montserrat', sans-serif;
font-size: 100%;
font-weight: 400;
margin: 0;
}
img {
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
display: block;
height: auto;
max-width: 100%;
}
.btn {
background-color: rgb(32, 91, 173);
border-radius: 99px;
color: white;
display: block;
font-size: 18px;
font-weight: 900;
letter-spacing: .02em;
line-height: 42px;
height: 42px;
padding: 0 40px;
text-decoration: none;
transition: background-color .4s ease-out;
width: fit-content;
&:hover {
background-color: rgb(222, 40, 112);
}
}
.page-header {
align-items: center;
display: flex;
height: 50vh;
justify-content: center;
}
#scroll-section {
position: relative;
min-height: 2700px;
}
.line-svg {
position: absolute;
height: calc(100% - 10rem);
top: 0;
min-width: 300px;
z-index: -1;
}
.container {
margin: 0 auto;
max-width: 1272px;
}
h1 {
color: white;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
h2 {
clip-path: polygon(0 0, 100% 0, 100% 100%, 0 100%);
color: white;
font-size: 62px;
font-weight: 900;
letter-spacing: .02em;
margin: 0;
padding-top: 72px;
position: relative;
width: 50%;
text-align: right;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
.layout-container {
padding-top: 8rem;
display: grid;
grid-template-columns: repeat(6, 1fr);
/* grid-template-columns: 1fr 1.2fr 4rem 1.2fr 1.2fr 8rem;
grid-template-rows: auto 6.5rem 6.5rem 5rem auto 6.5rem 5rem 5rem auto 7rem; */
}
.box {
background-color: white;
color: #333;
padding: 4rem;
h3 {
font-size: 42px;
font-weight: 900;
line-spacing: .02em;
margin: 0 0 18px;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
p {
font-size: 18px;
line-height: 1.25;
margin: 0 0 2em;
}
}
.box-1 {
grid-column: 3 / span 3;
grid-row: span 2;
}
.image-1 {
grid-column: 1 / span 2;
grid-row: 2 /span 2;
margin-top: 100px;
}
.image-2 {
align-self: end;
grid-column: 6 / span 1;
grid-row: 5;
}
.image-3 {
grid-column: 1 / span 2;
justify-self: end;
margin-top: 3rem;
}
.box-2 {
grid-column: 2 / span 3;
margin-top: 3rem;
grid-row: span 2;
}
.box-3 {
grid-column: 3 / span 3;
margin-top: 8em;
}
.box-4 {
grid-column: 1 / span 3;
margin-top: 12rem;
margin-bottom: -5rem;
}
.bottom {
height: 50vh;
}
// Add text-stroke for h2
gsap.registerPlugin(ScrollTrigger, DrawSVGPlugin, GSDevTools);
const main = gsap.timeline({
scrollTrigger: {
trigger: '#scroll-section',
scrub: true,
start: "top center",
end: "bottom center"
}
});
main
.from('.line-svg path', {drawSVG: 0, duration: 8.44},0)
.to('body', {backgroundColor: 'rgb(178, 203, 235)', duration: 7.44}, 1)
.from('h2', {clipPath:'polygon(0 0, 0% 0, 0% 100%, 0 100%)', duration: .55},.83)
.from('.box-1', {opacity: 0, duration: .5, ease: 'power3.out'}, 1.5)
.from('.image-1', {clipPath: 'polygon(0 100%, 100% 100%, 100% 100%, 0% 100%)', opacity: 0, duration: .5, ease: 'power3.out'}, 2.15)
.from('.box-2', {opacity: 0, duration: .5, ease: 'power3.out'}, 2.7)
.from('.image-2', {clipPath: 'polygon(0 100%, 100% 100%, 100% 100%, 0% 100%)', opacity: 0, duration: .5, ease: 'power3.out'}, 3.7)
.from('.box-3', {opacity: 0, duration: .5, ease: 'power3.out'}, 5.21)
.from('.image-3', {clipPath: 'polygon(0 100%, 100% 100%, 100% 100%, 0% 100%)', opacity: 0, duration: .5, ease: 'power3.out'}, 6.2)
.from('.box-4', {opacity: 0, duration: .5, ease: 'power3.out'}, 7.37)
// GSDevTools.create({animation: main});
Also see: Tab Triggers