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.
<link href='//fonts.googleapis.com/css?family=Asap:400,700' rel='stylesheet' type='text/css'>
<script src="https://kit.fontawesome.com/a24879a822.js" crossorigin="anonymous"></script>
<link href="https://www.dafontfree.net/embed/bW9udHJlYWwtbWVkaXVtLXJlZ3VsYXImZGF0YS8yNi9tLzEzNTAxOC9Nb250cmVhbC1NZWRpdW0udHRm" rel="stylesheet" type="text/css"/>
<div class="viewport">
<div id="scroll-container" class="scroller">
<div class="fullPageSection blueBall ">
<div class="blueBallItem"></div>
<div class="titleSection">
<h1>Jake's GSAP Testing Environment</h1>
</div>
</div>
<div class="fullPageSection red2">
<div id="quote2">Testing Testing Testing.</div>
</div>
<div class="fullPageSection red">
<div id="quote">Web Development</div>
</div>
<div class="fullPageSection textUp">
<div id="quoteUp">SplitText makes it easy to break apart the text in an HTML element so that each character, word, and/or line is wrapped in its own div tag. </div>
</div>
<div class="fullPageSection yellow white">
<div class="video">
<div class="canvas-container">
<canvas id="hero-lightpass" />
</div>
</div>
</div>
<div class="fullPageSection yellowtwo">
<div class="video2">
<div class="canvas-container2">
<canvas id="hero-lightpass2" />
</div>
</div>
</div>
<div class="fullPageSection whiteBg roundedBoxes">
<div class="roundBoxes">
<div class="roundBox">
<div class="overlay"></div>
<img src="https://source.unsplash.com/random/?mushroom&500x500">
<div class="textDiv">
<h2>Lorem ipsum</h2>
</div>
<div class="iconDiv">
<i class="fa-solid fa-2x fa-arrow-up-right"></i>
</div>
</div>
<div class="roundBox">
<div class="overlay"></div>
<img src="https://source.unsplash.com/random/?tree&500x500">
<div class="textDiv">
<h2>Lorem ipsum</h2>
</div>
<div class="iconDiv">
<i class="fa-solid fa-2x fa-arrow-up-right"></i>
</div>
</div>
<div class="roundBox">
<div class="overlay"></div>
<img src="https://source.unsplash.com/random/?forest&500x500">
<div class="textDiv">
<h2>Lorem ipsum</h2>
</div>
<div class="iconDiv">
<i class="fa-solid fa-2x fa-arrow-up-right"></i>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="fullPageSection rotateImg">
<img class="rotateImage" src="https://i.imgur.com/imgEL3S.png">
</div>
<div class="fullPageSection loader">
<div class="blackQuoteParent">
<div id="quoteBlack">Digital.</div>
</div>
</div>
* {
font-family: 'montreal-medium-regular', sans-serif;
}
body {
overflow:hidden;
font-family:'Asap';
padding:0;
margin:0;
}
.blackdiv {
background: #000!important;
width:100%;
height:200px;
}
.whiteBg {
background:#fff!important;
}
.roundedBoxes {
width:100%; height:100%;
display:flex; justify-content:center; align-items:center;
}
.roundBoxes {
height:70%; width:90%;
/* background:#999!important; */
display:flex; flex-flow:row; justify-content:space-between;
}
.roundBox {
background:#fff;
width:30%;
height:100%;
border-radius:100px;
border-radius: 50px;
background: #e0e0e0;
box-shadow: -20px 20px 60px #bebebe,
20px -20px 60px #ffffff;
position:relative;
cursor:pointer;
}
.roundBox .overlay {
width:100%;
height:100%;
background:rgba(0,0,0,0.3);
position:absolute;
top:0;left:0;
border-radius:50px;
}
.roundBox img {
object-fit:cover;
width:100%;
height:100%;
border-radius:50px;
}
.roundBox:hover .iconDiv {
bottom:calc(50% - 150px); left:50%;
transform:translate(-50%,-50%)
}
.roundBox:hover .textDiv {
bottom:calc(50% - 70px); left:50%;
transform:translate(-50%,-50%)
}
.textDiv {
height:60px; width:auto;
background:#fff;
display:inline-flex;
justify-content:center; align-items:center;
position:relative;
padding:0px 20px;
border-radius:20px;
transition:0.6s all ease-in-out;
position:absolute;
bottom:130px; left:50px;
}
.textDiv h2 {
font-weight:700;
}
.iconDiv {
padding:10px;
background:#fff;
height:40px; width:40px;
position:absolute; bottom:50px; left:50px;
transition:0.6s all ease-in-out;
display:flex; justify-content:center; align-items:center;
border-radius:20px;
}
.hidden {
/* display:none!important; */
transition: 0.7s all ease-in-out;
opacity:0;
z-index:-999;
transform:translateY(-100%)
}
.yellow {
background:#f5f5f7; display:flex;
justify-content:center;
align-items:center;
}
.yellow2{
background:black!important;
display:flex;
justify-content:center;
align-items:center;
}
.yellowtwo {
background:black!important;
display:flex;
justify-content:center;
align-items:center;
}
.textUp {
display:flex;
justify-content:center;
align-items:center;
}
.video {
width:75%;
height:100%;
background:#f5f5f7;
}
.video2 {
width:75%;
height:100%;
background:black
}
.red {
background:black!important;
display:flex;
align-items:center;
justify-content:center;
}
.red2 {
background:red!important;
display:flex;
align-items:center;
justify-content:center;
}
.fullPageSection {
height:100vh;
display:flex;
overflow:hidden;
width:100%;
background:blue;
margin-bottom:-1px
}
#quote{
width:100%;
font-size:10vw;
line-height:50px;
color:#dedede;
display:block;
margin:0 auto;
font-weight:700;
text-align:center;
line-height:1.5;
}
#quote2{
width:100%;
font-size:60px;
font-weight:bold;
line-height:50px;
color:#dedede;
text-align:center;
display:inline-block: margin:0 auto;
line-height:1.5;
}
.blueBall {
background:#ff4757!important;
position:relative;
}
.blueBallItem {
height:100%;
width:100vh;
border-radius:10000px;
background:#3742fa;
position:absolute;
bottom:-50vh;
opacity:0.2;
left:100vw
}
#quoteUp {
width:50%;
font-size:32px;
line-height:50px;
color:#dedede;
display:block;
margin:0 auto;
text-align:center;
line-height:1.5
}
button {
padding:10px;
margin: 20px 0;
}
#viewport {
overflow: hidden;
position: fixed;
height: 100%;
width: 100%;
top: 0;
left: 0;
right: 0;
bottom: 0;
}
.scroller {
height: 100vh;
}
#parent {
overflow: visible;
width: 100%;
/* set a height because the contents are position: absolute, thus natively there's no height */
height: 2400px;
background-image:
linear-gradient(rgba(255,255,255,.07) 2px, transparent 2px),
linear-gradient(90deg, rgba(255,255,255,.07) 2px, transparent 2px),
linear-gradient(rgba(255,255,255,.06) 1px, transparent 1px),
linear-gradient(90deg, rgba(255,255,255,.06) 1px, transparent 1px);
background-size: 100px 100px, 100px 100px, 20px 20px, 20px 20px;
background-position: -2px -2px, -2px -2px, -1px -1px, -1px -1px;
}
.titleSection {
width:100%;
height:100%;
display:flex;
justify-content:center;
align-items:center; perspective: 600px;
}
canvas {
width:100%;
height:auto;
padding:50px;}
h1 {
color:#fff;
font-size:36px;
font-weight:300
}
.white {
background:#f5f5f7;
}
.white2 {
background:#fff
}
.canvas-container {
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding:50px 0px;
background:#f5f5f7;
}
.canvas-container2 {
width: 100%;
height: 100vh;
display: flex;
justify-content: center;
align-items: center;
padding:50px 0px;
}
.rotateImg {
display:flex;
justify-content:center;
align-items:center;
position:fixed!important;
top:0;
left:0;
background:#000!important;
z-index:444;
}
.loader {
display:flex;
justify-content:center;
align-items:center;
position:fixed!important;
top:0;
left:0;
background:#000!important;
color:#fff;
z-index:443;
}
.rotateImg img {
width:400px;
height:400px;
}
#quoteBlack{
width:100%;
font-size:10vw;
line-height:50px;
color:#dedede;
display:block;
margin:0 auto;
font-weight:700;
text-align:center;
line-height:1.5;
}
.blackQuoteParent {
height:400px;
overflow:hidden;
}
/*
See https://www.greensock.com/splittext/ for details.
This demo uses SplitText which is a membership benefit of Club GreenSock, https://www.greensock.com/club/
*/
gsap.registerPlugin(SplitText, ScrollTrigger);
//S M O O T H S C R O L L E R S T A R T
const scroller = document.querySelector('.scroller');
const bodyScrollBar = Scrollbar.init(scroller, { damping: 0.1, delegateTo: document, alwaysShowTracks: true, plugins: { overscroll : { effect: 'bounce', damping: 0.15, maxOverscroll: 80}} });
ScrollTrigger.scrollerProxy(".scroller", {
scrollTop(value) {
if (arguments.length) {
bodyScrollBar.scrollTop = value;
}
return bodyScrollBar.scrollTop;
}
});
bodyScrollBar.addListener(ScrollTrigger.update);
ScrollTrigger.defaults({ scroller: scroller });
//S M O O T H S C R O L L E R E N D
//S P L I T T E X T S T A R T
var tl = gsap.timeline(),
mySplitText = new SplitText("#quote", { type: "words,chars" }),
chars = mySplitText.chars; //an array of all the divs that wrap each character
gsap.set("#quote", { perspective: 400 });
//S P L I T T E X T E N D
//S P L I T T E X T 2 S T A R T
var t2 = gsap.timeline(),
mySplitText2 = new SplitText("#quote2", { type: "words" }),
chars2 = mySplitText2.words; //an array of all the divs that wrap each character
gsap.set("#quote2", { perspective: 400 });
//S P L I T T E X T 2 E N D
//RED
t2.from(chars2, {
duration: 0.8,
opacity: 0,
y:-100,
ease: "Power3.easeOut",
stagger:1,
scrollTrigger: {
trigger: ".red2",
start: "top top",
end: "+700",
scrub: true,
pin: ".red2",
}
});
//RED
tl.from(chars, {
duration: 0.8,
opacity: 0,
y:-100,
ease: "Power3.easeOut",
stagger: 0.1,
scrollTrigger: {
trigger: ".red",
start: "-=200",
end: "+300",
scrub: true,
pin: false,
}
});
//TEXT UP
gsap.from("#quoteUp", {
duration: 0.8,
delay:0,
y: 200,
opacity:0,
ease: "Power3.easeOut",
scrollTrigger: {
trigger: ".textUp",
start: "-=200",
end: "+500",
scrub: true,
pin: false,
}
});
//B A L L A N I M A T I O N
gsap.from(".blueBallItem", {
duration: 0.8,
delay:0,
left:0,
ease: "Power3.easeOut",
scrollTrigger: {
trigger: ".blueBall",
start: "top top",
end: "+4500",
scrub: true,
pin: false,
}
});
//S H R I N K I N G V I D E O
gsap.from(".video", {
duration: 0.8,
delay:1,
width:"100%",
ease: "Power3.easeOut",
scrollTrigger: {
trigger: ".yellow",
start: "top top",
end: "+3200",
scrub: 1,
pin: true,
}
});
//R O T A T I N G I C O N
TweenMax.to(".rotateImage", {rotation:"360", duration: 8, ease: 'none', repeat:-1});
//S H R I N K I N G V I D E O 2
gsap.from(".video2", {
duration: 0.8,
delay:1,
width:"100%",
ease: "Power3.easeOut",
scrollTrigger: {
trigger: ".yellowtwo",
start: "top top",
end: "+3200",
scrub: 1,
pin: ".yellowtwo",
}
});
//T I T L E S E C T I O N
gsap.from(".titleSection", {
y:200,
duration: 0.8,
rotationX: 75,
stagger: 0.1,
transformOrigin: "top center",
z: 150,
opacity: 0,
ease: "Power3.easeOut",
scrollTrigger: {
trigger: ".blueBall",
}
});
const canvas = document.getElementById("hero-lightpass");
const context = canvas.getContext("2d");
canvas.width = screen.width;
canvas.height = screen.height;
const frameCount = 195;
const currentFrame = (index) => {
let addedIndex = String(index).padStart(4, "0")
console.log(addedIndex)
return `https://www.apple.com/105/media/us/apple-vision-pro/2023/7e268c13-eb22-493d-a860-f0637bacb569/anim/360/large/${
addedIndex
}.jpg`;
}
console.log("IMAGE: " + currentFrame)
const images = [];
const seq = {
frame: 0
};
for (let i = 0; i < frameCount; i++) {
const img = new Image();
img.src = currentFrame(i);
images.push(img);
}
gsap.to(seq, {
frame: frameCount - 1,
snap: "frame",
ease: "none",
scrollTrigger: {
trigger: ".canvas-container",
// start: "-=400",
start: "top top",
end: "+=3000",
pin: false,
scrub: true,
},
onUpdate: render
});
images[0].onload = render;
x = (canvas.width - images[0].width ) * 0.5, // this = image loaded
y = (canvas.height - images[0].height) * 0.5;
function render() {
const canvasW = canvas.width
context.clearRect(0, 0, canvas.width, canvas.height);
context.drawImage(images[seq.frame], canvas.width / 2 - images[0].width / 2 , canvas.height / 2 - images[0].height / 2 + 150);
}
// L O A D E R
function hideLoader() {
const loaderSection = document.querySelector(".rotateImg")
loaderSection.classList.add("hidden")
}
const myTimeout = setTimeout(hideLoader, 3000);
// L O A D E R 2
function hideLoader2() {
const loaderSection2 = document.querySelector(".loader")
loaderSection2.classList.add("hidden")
}
const myTimeout2 = setTimeout(hideLoader2, 5500);
var timeline = new TimelineMax();
//BATCH STAGGER
ScrollTrigger.batch(".roundBox", {
onEnter: elements => {
gsap.from(elements, {
autoAlpha: 0,
y: 60,
stagger: 0.15
});
},
});
// ************************************************************
const canvas2 = document.getElementById("hero-lightpass2");
const context2 = canvas2.getContext("2d");
canvas2.width = screen.width;
canvas2.height = screen.height;
const frameCount2 = 100;
const currentFrame2 = (index2) =>
`https://cdn.cuberto.com/fp/img/hero/hero_${
index2 + 1
}.jpg`;
const images2 = [];
const seq2 = {
frame: 0
};
for (let i2 = 0; i2 < frameCount2; i2++) {
const img2 = new Image();
img2.src = currentFrame2(i2);
images2.push(img2);
}
gsap.to(seq2, {
frame: frameCount2 - 1,
snap: "frame",
ease: "none",
scrollTrigger: {
trigger: ".canvas-container2",
// start: "-=400",
start: "top top",
end: "+=3000",
pin: false,
scrub: true,
},
onUpdate: render2
});
images2[0].onload = render2;
function render2() {
context2.clearRect(0, 0, canvas2.width, canvas2.height);
context2.drawImage(images2[seq2.frame], 0, 0);
}
//text up animation
gsap.to("#quoteBlack", {
duration: 1,
delay:4.2,
y:-350,
ease: "Power3.easeOut",
});
Also see: Tab Triggers