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.
<h1 class="header-section">Scroll down for pinned content animation</h1>
<div class="content-container">
<div class="left-content">
<img id="img1" class="imageToShow" src="https://images.unsplash.com/photo-1586410073908-5f314173d3a5?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MTUxODczMTl8&ixlib=rb-4.0.3&q=80&w=400" alt="kitty">
<img id="img2" class="imageToShow" src="https://images.unsplash.com/photo-1574144611937-0df059b5ef3e?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MTUxODczMTl8&ixlib=rb-4.0.3&q=80&w=400" alt="kitty">
<blockquote id="text1" class="textToShow" cite="https://www.youtube.com/watch?v=PKffm2uI4dk">
<p>Cat ipsum dolor sit amet, attack the child i show my fluffy belly but it's a trap!</p>
<footer>— Fluffy, the kitten <cite>Sad Cat Diary</cite></footer>
</blockquote>
<img id="img3" class="imageToShow" src="https://images.unsplash.com/photo-1615678815958-5910c6811c25?crop=entropy&cs=tinysrgb&fit=max&fm=jpg&ixid=M3wzMjM4NDZ8MHwxfHJhbmRvbXx8fHx8fHx8fDE3MTUxODczMTl8&ixlib=rb-4.0.3&q=80&w=400" alt="kitty">
</div>
<div class="right-content">
<p class="contentMarker" data-marker-content="img1">Cat ipsum dolor sit amet, attack the child i show my fluffy belly but it's a trap!</p>
<p>if you pet it i will tear up your hand, but chase ball of string. Poop on couch hate dog, yet mouse and catch eat throw up catch eat throw up bad birds curl into a furry donut. Bite nose of your human you have cat to be kitten me right meow kitty poochy put toy mouse in food bowl run out of litter box at full speed , for stand with legs in litter box, but poop outside. Eat all the power cords. X poop in the plant pot. Pooping rainbow while flying in a toasted bread costume in space.</p>
<p>Hiding behind the couch until lured out by a feathery toy instead of drinking water from the cat bowl, make sure to steal water from the toilet so hide at bottom of staircase to trip human stinky cat, or favor packaging over toy, sit on human they not getting up ever so x. Run outside as soon as door open caticus cuteicus 𝕄𝔼𝕆𝕎, and chase imaginary bugs, and scratch my tummy actually i hate you now fight me scratch leg; meow for can opener to feed me.</p>
<p class="contentMarker" data-marker-content="img2">do not try to mix old food with new one to fool me! do i like standing on litter cuz i sits when i have spaces, my cat buddies have no litter i live in luxury cat life and throw down all the stuff in the kitchen. Find empty spot in cupboard and sleep all day i want to go outside let me go outside nevermind inside is better so i like cats because they are fat and fluffy scratch my tummy actually i hate you now fight me and lick the other cats thug cat.</p>
<p>When owners are asleep, cry for no apparent reason love you, then bite you push your water glass on the floor or swipe at owner's legs and toy mouse squeak roll over. Cough furball into food bowl then scratch owner for a new one. Damn that dog cat walks in keyboard so hide at bottom of staircase to trip human flee in terror at cucumber discovered on floor.</p>
<p>Meow and walk away meow for food, then when human fills food dish, take a few bites of food and continue meowing scream at teh bath and the door is opening! how exciting oh, it's you, meh so brown cats with pink ears hey! you there, with the hands but fight an alligator and win. Use lap as chair howl on top of tall thing be a nyan cat, feel great about it, be annoying 24/7 poop rainbows in litter box all day, chirp at birds leave fur on owners clothes, scratch at the door then walk away.</p>
<p>Catasstrophe i’m so hungry i’m so hungry but ew not for that so run in circles, or i like fish. Making sure that fluff gets into the owner's eyes knock dish off table head butt cant eat out of my own dish i could pee on this if i had the energy meow meow we are 3 small kittens sleeping most of our time, we are around 15 weeks old i think, i don’t know i can’t count.</p>
<p>Grass smells good the fat cat sat on the mat bat away with paws there's a forty year old lady there let us feast. Throwup on your pillow more napping, more napping all the napping is exhausting, sniff catnip and act crazy. Trip owner up in kitchen i want food. I bet my nine lives on you-oooo-ooo-hooo. Pee in human's bed until he cleans the litter box. Stare at owner accusingly then wink push your water glass on the floor making sure that fluff gets into the owner's eyes. Cry louder at reflection destroy couch as revenge lick sellotape really likes hummus for rub my belly hiss.</p>
<p class="contentMarker" data-marker-content="text1">Jump launch to pounce upon little yarn mouse, bare fangs at toy run hide in litter box until treats are fed chase laser or roll on the floor purring your whiskers off for pretend you want to go out but then don't play time. Munch, munch, chomp, chomp pooping rainbow while flying in a toasted bread costume in space you call this cat food sleep on my human's head but meow to be let in rub face on owner.</p>
<p>Eat half my food and ask for more hell is other people cough furball into food bowl then scratch owner for a new one, lick human with sandpaper tongue yet i'm bored inside, let me out i'm lonely outside, let me in i can't make up my mind whether to go in or out, guess i'll just stand partway in and partway out, contemplating the universe for half an hour how dare you nudge me with your foot?!?! leap into the air in greatest offense!</p>
<p>Run at 3am your pillow is now my pet bed but use lap as chair poop in a handbag look delicious and drink the soapy mopping up water then puke giant foamy fur-balls wake up human for food at 4am. Chase the pig around the house relentlessly pursues moth good morning sunshine cat gets stuck in tree firefighters try to get cat down firefighters get stuck in tree cat eats firefighters' slippers purr or scoot butt on the rug yet dead stare with ears cocked. Poop in litter box, scratch the walls i like fish stare at guinea pigs.</p>
<p>Cats secretly make all the worlds muffins sit on the laptop but toy mouse squeak roll over, or it's 3am, time to create some chaos or look at dog hiiiiiisssss.</p>
<p>Meow and walk away. Scratch the postman wake up lick paw wake up owner meow meow. Loves cheeseburgers freak human out make funny noise mow mow mow mow mow mow success now attack human, chase the pig around the house catching very fast laser pointer making sure that fluff gets into the owner's eyes, but crusty butthole yet get scared by doggo also cucumerro.</p>
<p>Gnaw the corn cob sniff other cat's butt and hang jaw half open thereafter toy mouse squeak roll over throw down all the stuff in the kitchen. Destroy couch lick butt.</p>
<p class="contentMarker" data-marker-content="img3">Pooping rainbow while flying in a toasted bread costume in space has closed eyes but still sees you hit you unexpectedly peer out window, chatter at birds, lure them to mouth so hiss and stare at nothing then run suddenly away so stare at wall turn and meow stare at wall some more meow again continue staring yet poop on grasses.</p>
<p>Kick up litter instantly break out into full speed gallop across the house for no reason so i bet my nine lives on you-oooo-ooo-hooo as lick i the shoes lay on arms while you're using the keyboard or my slave human didn't give me any food so i pooped on the floor.</p>
<p>Lick butt and make a weird face catch mouse and gave it as a present so i do no work yet get food, shelter, and lots of stuff just like man who lives with us ignore the squirrels, you'll never catch them anyway bite off human's toes but climb leg, lick the curtain just to be annoying.</p>
<p>Soft kitty warm kitty little ball of furr my water bowl is clean and freshly replenished, so i'll drink from the toilet, find something else more interesting, or cat jumps and falls onto the couch purrs and wakes up in a new dimension filled with kitty litter meow meow yummy there is a bunch of cats hanging around eating catnip , but cat mojo but man running from cops stops to pet cats, goes to jail so stand with legs in litter box, but poop outside.</p>
<p>Step on your keyboard while you're gaming and then turn in a circle behind the couch. Gate keepers of hell give attitude, for jump five feet high and sideways when a shadow moves. Bird bird bird bird bird bird human why take bird out i could have eaten that sit on human they not getting up ever.</p>
<p>I am the best open the door, let me out, let me out, let me-out, let me-aow, let meaow, meaow! put toy mouse in food bowl run out of litter box at full speed for if it fits, i sits but murr i hate humans they are so annoying for eat the fat cats food cat sit like bread. Trip owner up in kitchen i want food.</p>
</div>
</div>
<h1 class="header-section">That's it!</h1>
<a class="gsap-logo" target="_blank" href="https://gsap.com/docs/v3">
<img src="https://assets.codepen.io/16327/gsap-logo-light.svg" alt="" />
</a>
.content-container {
display: flex;
}
.content-container > * {
width: 50%;
}
.right-content {
padding-right: 15px;
}
.left-content {
height: 100vh;
position: relative;
}
.left-content > * {
position: absolute;
left: 50%;
top: 50%;
opacity: 0;
visibility: hidden;
}
@media screen and (max-width: 800px) {
.left-content {
display: none;
}
.right-content {
padding-left: 15px;
}
}
.header-section {
text-align: center;
padding: 1rem 6rem;
}
.gsap-logo {
left: 1rem;
rightL unser
}
console.clear();
gsap.defaults({overwrite: 'auto'});
gsap.set(".left-content > *", {xPercent: -50, yPercent: -50});
// Set up our scroll trigger
const ST = ScrollTrigger.create({
trigger: ".content-container",
start: "top top",
end: "bottom bottom",
onUpdate: getCurrentSection,
pin: ".left-content"
});
const contentMarkers = gsap.utils.toArray(".contentMarker");
// Set up our content behaviors
contentMarkers.forEach(marker => {
marker.content = document.querySelector(`#${marker.dataset.markerContent}`);
if(marker.content.tagName === "IMG") {
gsap.set(marker.content, {transformOrigin: "center"});
marker.content.enter = function() {
gsap.fromTo(marker.content, {autoAlpha: 0, rotateY: -30}, {duration: 0.3, autoAlpha: 1, rotateY: 0});
}
} else if(marker.content.tagName === "BLOCKQUOTE") {
gsap.set(marker.content, {transformOrigin: "left center"});
marker.content.enter = function() {
gsap.fromTo(marker.content, {autoAlpha: 0, rotateY: 50}, {duration: 0.3, autoAlpha: 1, rotateY: 0});
}
}
marker.content.leave = function() {
gsap.to(marker.content, {duration: 0.1, autoAlpha: 0});
}
});
// Handle the updated position
let lastContent;
function getCurrentSection() {
let newContent;
const currScroll = scrollY;
// Find the current section
contentMarkers.forEach(marker => {
if(currScroll > marker.offsetTop) {
newContent = marker.content;
}
});
// If the current section is different than that last, animate in
if(newContent
&& (lastContent == null
|| !newContent.isSameNode(lastContent))) {
// Fade out last section
if(lastContent) {
lastContent.leave();
}
// Animate in new section
newContent.enter();
lastContent = newContent;
}
}
const media = window.matchMedia("screen and (max-width: 600px)");
ScrollTrigger.addEventListener("refreshInit", checkSTState);
checkSTState();
function checkSTState() {
if(media.matches) {
ST.disable();
} else {
ST.enable();
}
}
Also see: Tab Triggers