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 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.
<div class="capsule-buttons">
<div class="capsule-button-container">
<svg class="capsule-button-border" xmlns="http://www.w3.org/2000/svg" width="29" height="29" viewBox="0 0 29 29" fill="none">
<rect x="0.5" y="0.5" width="28" height="28" stroke="#230E03"/>
</svg>
<button class="first capsule-button"></button>
<button class="second capsule-button"></button>
<button class="third capsule-button"></button>
<button class="fourth capsule-button"></button>
</div>
</div>
<div class="trigger-wrap">
<section class="black">
<div class="p-wrap p-wrap-1">
<a href="/products/black-dress">
<div class="panel blue">
<div class="product-info d-none">
<h5>THE MINI DRESS</h5>
<div class="price">£400</div>
</div>
</div>
<div class="panel red"></div>
<div class="panel orange"></div>
<div class="panel purple"></div>
</a>
</div>
<div class="p-wrap p-wrap-2">
<div class="panel2 blue"></div>
<div class="panel2 red"></div>
<div class="panel2 orange"></div>
<div class="panel2 purple"></div>
</div>
<div class="p-wrap p-wrap-3">
<div class="panel3 blue"></div>
<div class="panel3 red"></div>
<div class="panel3 orange"></div>
<div class="panel3 purple"></div>
</div>
<div class="p-wrap p-wrap-4">
<div class="panel4 blue"></div>
<div class="panel4 red"></div>
<div class="panel4 orange"></div>
<div class="panel4 purple"></div>
</div>
<div class="p-wrap p-wrap-5">
<div class="panel5 blue"></div>
<div class="panel5 red"></div>
<div class="panel5 orange"></div>
<div class="panel5 purple"></div>
</div>
<div class="p-wrap p-wrap-6">
<div class="panel6 blue"></div>
<div class="panel6 red"></div>
<div class="panel6 orange"></div>
<div class="panel6 purple"></div>
</div>
</section>
<div class="text-wrap">
<div class="panel-text panel-text1 blue-text"><p>Blue</p></div>
<div class="panel-text panel-text2 red-text"><p>Red</p></div>
<div class="panel-text panel-text3 orange-text"><p>Orange</p></div>
<div class="panel-text panel-text4 purple-text"><p>Purple</p></div>
</div>
</div>
<footer class="footer">
<ul>
<li>footer list</li>
<li>footer list</li>
<li>footer list</li>
<li>footer list</li>
<li>footer list</li>
</ul>
</footer>
.trigger-wrap {
position: relative;
}
section.black {
width: 100vw;
height: 100vh;
position: fixed;
bottom: 0;
justify-content: space-around;
align-items: center;
background-color: transparent;
z-index: 999;
padding-left: 50px;
padding-right: 50px;
display: grid;
grid-template-columns: repeat(12,1fr);
grid-template-rows: repeat(12,1fr);
grid-column-gap: 10px;
grid-row-gap: 10px;
}
.text-wrap {
position: relative;
width: 100vw;
}
.panel-text {
position: relative;
left: 0%;
top: 0%;
right: 0%;
bottom: 0%;
z-index: unset;
width: 100%;
height: 100vh;
font-size: 200px;
text-transform: uppercase;
font-weight: 900;
background-color: black;
display: flex;
align-items: center;
justify-content: center;
}
.panel-text p {
font-size: 300px;
line-height: 100%;
font-family: "louizeregular", sans-serif;
text-transform: uppercase;
font-weight: 400;
z-index: 9999;
pointer-events: none;
}
.panel-text.blue-text {
color: black;
background: blue;
}
.panel-text.red-text {
color: pink;
background: red;
}
.panel-text.orange-text {
color: brown;
background: orange;
}
.panel-text.tomato-text {
color: pink;
background: light-pink;
}
.panel-text.purple-text {
color: yellow;
background: purple;
}
.p-wrap {
position: relative;
overflow: hidden;
width: 180px;
height: 209px;
}
.p-wrap-1 {
grid-area: 4 / 1 / span 5 / span 2;
margin-left: 60px;
}
.p-wrap-2 {
grid-area: 3 / 4 / span 5 / span 2;
margin-left: auto;
}
.p-wrap-3 {
grid-area: 3 / 8 / span 6 / span 2;
margin-top: 60px;
}
.p-wrap-4 {
grid-area: 4 / 11 / span 6 / span 2;
}
.p-wrap-5 {
grid-area: 8 / 2 / span 5 / span 2;
}
.p-wrap-6 {
grid-area: 7 / 6 / span 6 / span 2;
margin-top: 60px;
}
.panel, .panel2, .panel3, .panel4, .panel5, .panel6, .panel7 {
position: absolute;
left: 0%;
top: 0%;
right: 0%;
bottom: 0%;
z-index: 1;
width: 100%;
height: 100%;
}
.panel.blue {
background-color: blue;
background-image: url("https://ichef.bbci.co.uk/news/999/cpsprodpb/1751E/production/_123881559_02.jpg");
}
.panel.red {
background-color: red;
background-image: url("https://st.depositphotos.com/1000848/1312/i/600/depositphotos_13124937-stock-photo-roses-background.jpg");
}
.panel.orange {
background-color: orange;
background-image: url("https://media.gettyimages.com/photos/half-of-orange-on-the-heap-of-oranges-picture-id1205638014?s=612x612");
}
.panel.tomato {
background-color: tomato;
background-image: url("https://images-prod.healthline.com/hlcmsresource/images/AN_images/tomatoes-1296x728-feature.jpg");
}
.panel.purple {
background-color: purple;
background-image: url("https://img.freepik.com/free-vector/purple-watercolor-galaxy-background_23-2149248308.jpg?w=2000");
}
.panel2.blue {
background-color: blue;
background-image: url("https://images.unsplash.com/photo-1566228015668-4c45dbc4e2f5?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8NHx8Ymx1ZXxlbnwwfHwwfHw%3D&w=1000&q=80");
}
.panel2.red {
background-color: red;
background-image: url("https://upload.wikimedia.org/wikipedia/commons/e/e1/Strawberries.jpg");
}
.panel2.orange {
background-color: orange;
background-image: url("https://cdn.britannica.com/24/174524-050-A851D3F2/Oranges.jpg");
}
.panel2.purple {
background-color: purple;
background-image: url("https://img.freepik.com/free-vector/abstract-splashed-watercolor-textured-background_53876-8753.jpg?w=2000");
}
.panel3.blue {
background-color: blue;
background-image: url("https://images.unsplash.com/photo-1566228015668-4c45dbc4e2f5?ixlib=rb-4.0.3&ixid=MnwxMjA3fDB8MHxzZWFyY2h8NHx8Ymx1ZXxlbnwwfHwwfHw%3D&w=1000&q=80");
}
.panel3.red {
background-color: red;
background-image: url("https://upload.wikimedia.org/wikipedia/commons/e/e1/Strawberries.jpg");
}
.panel3.orange {
background-color: orange;
background-image: url("https://cdn.britannica.com/24/174524-050-A851D3F2/Oranges.jpg");
}
.panel3.purple {
background-color: purple;
background-image: url("https://img.freepik.com/free-vector/abstract-splashed-watercolor-textured-background_53876-8753.jpg?w=2000");
}
.panel4.blue {
background-color: blue;
background-image: url("https://ichef.bbci.co.uk/news/999/cpsprodpb/1751E/production/_123881559_02.jpg");
}
.panel4.red {
background-color: red;
background-image: url("https://st.depositphotos.com/1000848/1312/i/600/depositphotos_13124937-stock-photo-roses-background.jpg");
}
.panel4.orange {
background-color: orange;
background-image: url("https://media.gettyimages.com/photos/half-of-orange-on-the-heap-of-oranges-picture-id1205638014?s=612x612");
}
.panel4.tomato {
background-color: tomato;
background-image: url("https://images-prod.healthline.com/hlcmsresource/images/AN_images/tomatoes-1296x728-feature.jpg");
}
.panel4.purple {
background-color: purple;
background-image: url("https://img.freepik.com/free-vector/purple-watercolor-galaxy-background_23-2149248308.jpg?w=2000");
}
.panel5.blue {
background-color: blue;
background-image: url("https://ichef.bbci.co.uk/news/999/cpsprodpb/1751E/production/_123881559_02.jpg");
}
.panel5.red {
background-color: red;
background-image: url("https://st.depositphotos.com/1000848/1312/i/600/depositphotos_13124937-stock-photo-roses-background.jpg");
}
.panel5.orange {
background-color: orange;
background-image: url("https://media.gettyimages.com/photos/half-of-orange-on-the-heap-of-oranges-picture-id1205638014?s=612x612");
}
.panel5.tomato {
background-color: tomato;
background-image: url("https://images-prod.healthline.com/hlcmsresource/images/AN_images/tomatoes-1296x728-feature.jpg");
}
.panel5.purple {
background-color: purple;
background-image: url("https://img.freepik.com/free-vector/purple-watercolor-galaxy-background_23-2149248308.jpg?w=2000");
}
.panel6.blue {
background-color: blue;
background-image: url("https://ichef.bbci.co.uk/news/999/cpsprodpb/1751E/production/_123881559_02.jpg");
}
.panel6.red {
background-color: red;
background-image: url("https://st.depositphotos.com/1000848/1312/i/600/depositphotos_13124937-stock-photo-roses-background.jpg");
}
.panel6.orange {
background-color: orange;
background-image: url("https://media.gettyimages.com/photos/half-of-orange-on-the-heap-of-oranges-picture-id1205638014?s=612x612");
}
.panel6.tomato {
background-color: tomato;
background-image: url("https://images-prod.healthline.com/hlcmsresource/images/AN_images/tomatoes-1296x728-feature.jpg");
}
.panel6.purple {
background-color: purple;
background-image: url("https://img.freepik.com/free-vector/purple-watercolor-galaxy-background_23-2149248308.jpg?w=2000");
}
.capsule-buttons {
position: fixed;
top: 82px;
left: 0;
right: 0;
z-index: 99999;
width: 100vw;
display: flex;
justify-content: center;
background-color: #ffffff;
border-top: 1px solid #000000;
border-bottom: 1px solid #000000;
padding: 8px 0 4px;
}
.capsule-button-container {
position: relative;
padding: 5px;
margin-left: 7px;
display: flex;
justify-content: space-between;
row-gap: 10px;
}
.capsule-button-border {
position: absolute;
top: 0;
left: 0;
pointer-events: none;
}
button.capsule-button {
border: 1px solid #000000;
height: 19px;
width: 19px;
margin-left: 7px;
margin-right: 7px;
transition: 0.2s all ease-in-out;
}
button.capsule-button.first {
margin-left:0;
}
button.capsule-button:hover {
border: 1px solid #b9b9b9;
}
button.capsule-button.first {
background: blue;
}
button.capsule-button.second {
background: red;
}
button.capsule-button.third {
background: orange;
}
button.capsule-button.fourth {
background: purple;
$(document).ready(
function () {
if ($(".panel")[0]){
gsap.registerPlugin(ScrollTrigger);
// the magic helper function...
function getScrollPosition(animation, progress) {
let p = gsap.utils.clamp(0, 1, progress || 0),
st = animation.scrollTrigger,
containerAnimation = st.vars.containerAnimation;
if (containerAnimation) {
let time = st.start + (st.end - st.start) * p;
st = containerAnimation.scrollTrigger;
return st.start + (st.end - st.start) * (time / containerAnimation.duration());
}
return st.start + (st.end - st.start) * p;
}
gsap.set(".panel", { zIndex: (i, target, targets) => 1 + targets.length - i });
gsap.set(".panel2", { zIndex: (i, target, targets) => 1 + targets.length - i });
gsap.set(".panel3", { zIndex: (i, target, targets) => 1 + targets.length - i });
gsap.set(".panel4", { zIndex: (i, target, targets) => 1 + targets.length - i });
gsap.set(".panel5", { zIndex: (i, target, targets) => 1 + targets.length - i });
gsap.set(".panel6", { zIndex: (i, target, targets) => 1 + targets.length - i });
// gsap.set(".panel-text", { zIndex: (i, target, targets) => targets.length - i });
var images = gsap.utils.toArray('.panel:not(.purple)');
ScrollTrigger.create({
trigger: "section.black",
// pin: false,
start: () => "top top",
end: () => "+=" + ((images.length) * window.innerHeight),
invalidateOnRefresh: true,
});
images.forEach((image, i) => {
var tl = gsap.timeline({
scrollTrigger: {
trigger: ".trigger-wrap",
// start: () => "top -" + (window.innerHeight * (i + 0.5)),
start: () => "top -" + (window.innerHeight * i),
end: () => "+=" + window.innerHeight,
scrub: true,
invalidateOnRefresh: true,
}
})
tl
.fromTo(image, { height: () => { return "100%" } }, { height: () => { return "0%" } })
;
i === 0 && document.querySelector('button.capsule-button.first').addEventListener('click', autoScrollHere1)
function autoScrollHere1() {
gsap.to(window, {scrollTo: getScrollPosition(tl)});
}
i === 1 && document.querySelector('button.capsule-button.second').addEventListener('click', autoScrollHere2)
function autoScrollHere2() {
gsap.to(window, {scrollTo: getScrollPosition(tl)});
}
i === 2 && document.querySelector('button.capsule-button.third').addEventListener('click', autoScrollHere3)
function autoScrollHere3() {
gsap.to(window, {scrollTo: getScrollPosition(tl, 0)});
}
i === 2 && document.querySelector('button.capsule-button.fourth').addEventListener('click', autoScrollHere4)
function autoScrollHere4() {
gsap.to(window, {scrollTo: getScrollPosition(tl, 0.999)});
}
});
var images2 = gsap.utils.toArray('.panel2:not(.purple)');
images2.forEach((image, i) => {
var tl = gsap.timeline({
scrollTrigger: {
trigger: ".trigger-wrap",
// start: () => "top -" + (window.innerHeight * (i + 0.5)),
start: () => "top -" + (window.innerHeight * i),
end: () => "+=" + window.innerHeight,
scrub: true,
invalidateOnRefresh: true,
}
})
tl
.fromTo(image, { height: () => { return "100%" } }, { height: () => { return "0%" } })
;
});
var images3 = gsap.utils.toArray('.panel3:not(.purple)');
images3.forEach((image, i) => {
var tl = gsap.timeline({
scrollTrigger: {
trigger: ".trigger-wrap",
// start: () => "top -" + (window.innerHeight * (i + 0.5)),
start: () => "top -" + (window.innerHeight * i),
end: () => "+=" + window.innerHeight,
scrub: true,
invalidateOnRefresh: true,
}
})
tl
.fromTo(image, { height: () => { return "100%" } }, { height: () => { return "0%" } })
;
});
var images4 = gsap.utils.toArray('.panel4:not(.purple)');
images4.forEach((image, i) => {
var tl = gsap.timeline({
scrollTrigger: {
trigger: ".trigger-wrap",
// start: () => "top -" + (window.innerHeight * (i + 0.5)),
start: () => "top -" + (window.innerHeight * i),
end: () => "+=" + window.innerHeight,
scrub: true,
invalidateOnRefresh: true,
}
})
tl
.fromTo(image, { height: () => { return "100%" } }, { height: () => { return "0%" } })
;
});
var images5 = gsap.utils.toArray('.panel5:not(.purple)');
images5.forEach((image, i) => {
var tl = gsap.timeline({
scrollTrigger: {
trigger: ".trigger-wrap",
// start: () => "top -" + (window.innerHeight * (i + 0.5)),
start: () => "top -" + (window.innerHeight * i),
end: () => "+=" + window.innerHeight,
scrub: true,
invalidateOnRefresh: true,
}
})
tl
.fromTo(image, { height: () => { return "100%" } }, { height: () => { return "0%" } })
;
});
var images6 = gsap.utils.toArray('.panel6:not(.purple)');
images6.forEach((image, i) => {
var tl = gsap.timeline({
scrollTrigger: {
trigger: ".trigger-wrap",
// start: () => "top -" + (window.innerHeight * (i + 0.5)),
start: () => "top -" + (window.innerHeight * i),
end: () => "+=" + window.innerHeight,
scrub: true,
invalidateOnRefresh: true,
}
})
tl
.fromTo(image, { height: () => { return "100%" } }, { height: () => { return "0%" } })
;
});
};
}
)
$(document).ready(
function() {
if ($(".black")[0]) {
gsap.registerPlugin(ScrollTrigger);
var tl3 = gsap.timeline({
scrollTrigger: {
trigger: ".footer",
start: "top bottom",
end: "bottom bottom",
toggleActions: 'play none none reset',
markers: true,
}
})
tl3.to('.black', {position:'absolute', bottom: 0})
var progresstimeline1 = gsap.timeline({
scrollTrigger: {
id: "box",
trigger: ".panel-text2",
scrub: true,
start: "top bottom",
end: "bottom bottom",
toggleActions: 'play none none reset',
markers: true,
}
})
progresstimeline1
.to('.capsule-button-border', { x: 33})
;
var progresstimeline2 = gsap.timeline({
scrollTrigger: {
id: "box",
trigger: ".panel-text3",
scrub: true,
start: "top bottom",
end: "bottom bottom",
markers: true,
}
})
progresstimeline2
.to('.capsule-button-border', { x: 66})
;
var progresstimeline3 = gsap.timeline({
scrollTrigger: {
id: "box",
trigger: ".panel-text4",
scrub: true,
start: "top bottom",
end: "bottom bottom",
markers: true,
}
})
progresstimeline3
.to('.capsule-button-border', { x: 99})
;
}
}
);
Also see: Tab Triggers