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.
<script src="https://cdn.tailwindcss.com"></script>
<div class="wrapper">
<div class="empty h-[100vh] flex justify-center items-center">
Scroll Down
</div>
<div class="section-1">
<div class="relative flex items-center lg:h-section bg-tertiary pt-24 pb-32 xs:py-32 lg:py-24">
<div class="relative mx-auto max-w-xl px-4 xxs:px-8 text-center md:max-w-2xl lg:max-w-6xl xl:max-w-7xl lg:px-8 ">
<div class="">
<h2 class="strapline text-lg font-semibold text-primary">Deploy smarter</h2>
<p class="header mt-2 text-2xl xxs:text-3xl font-semibold tracking-tight text-slate-700">Lorem ipsum dolor sit, amet consectetur</p>
<p class="description mx-auto mt-5 max-w-prose px-2 text-xl text-gray-500">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Omnis adipisci quo minus, dicta eveniet itaque unde vel eius? Eum, quae.</p>
</div>
<div class="mt-20">
<div class="grid grid-cols-1 gap-8 xl:gap-12 lg:grid-cols-3">
<div class="card pt-6">
<div class="flow-root min-h-[360px] shadow-sm rounded-lg bg-gray-50 px-6 pb-8">
<div class="-mt-6">
<div class="card__icon">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQikvMfXSm_KGdWaPI9y-t-oXE_v5tYlmD2uw&usqp=CAU" alt="" class="w-32 mx-auto" />
</div>
<h3 class="card__header mt-8 text-xl font-semibold leading-8 tracking-tight text-gray-900">Adipisicing</h3>
<p class="card__description mt-5 text-base leading-7 text-gray-600">Ac tincidunt sapien vehicula erat auctor pellentesque rhoncus. Et magna sit morbi lobortis.</p>
</div>
</div>
</div>
<div class="card pt-6">
<div class="flow-root min-h-[360px] shadow-sm rounded-lg bg-gray-50 px-6 pb-8">
<div class="-mt-6">
<div class="card__icon">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQikvMfXSm_KGdWaPI9y-t-oXE_v5tYlmD2uw&usqp=CAU" alt="" class="w-32 mx-auto" />
</div>
<h3 class="card__header mt-8 text-xl font-semibold leading-8 tracking-tight text-gray-900">Lorem ipsum</h3>
<p class="card__description mt-5 text-base leading-7 text-gray-600">
Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptate id esse odio adipisci sunt nisi dolor minima corporis recusandae! Aspernatur.
</p>
</div>
</div>
</div>
<div class="card pt-6">
<div class="flow-root min-h-[360px] shadow-sm rounded-lg bg-gray-50 px-6 pb-8">
<div class="-mt-6">
<div class="card__icon">
<img src="https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQikvMfXSm_KGdWaPI9y-t-oXE_v5tYlmD2uw&usqp=CAU" alt="" class="w-32 mx-auto" />
</div>
<h3 class="card__header mt-8 text-xl font-semibold leading-8 tracking-tight text-gray-900">Voluptate id</h3>
<p class="card__description mt-5 text-base leading-7 text-gray-600">Lorem ipsum dolor sit amet consectetur adipisicing elit. Tenetur, ut magni? Veniam autem harum excepturi fuga tempore inventore.</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
<div class="section-2">
<div class="${this._elementName}" id="#${this._elementName}">
<div class="bg-slate-500 flex items-end justify-center h-4/6 xl:h-[65vh] pt-24 lg:pt-16 xl:pt-0">
<div class="bg-primary w-full">
<div class="max-w-xl mx-auto pb-24 px-4 xxs:pb-12 sm:pb-24 xxs:px-8 lg:relative lg:max-w-6xl xl:max-w-[1440px] xl:px-0 lg:z-10 lg:pb-0">
<div class="relative w-full xxs:max-w-xl xs:mx-auto lg:mx-auto lg:grid lg:max-w-7xl lg:grid-cols-3 lg:gap-8 ">
<!-- Image Wrapper -->
<div class="relative -mt-32 lg:-my-8 lg:pb-0">
<!-- <div aria-hidden="true" class="absolute inset-x-0 top-0 h-1/2 bg-white lg:hidden"></div> -->
<div class="mx-auto max-w-xl lg:h-full lg:p-0">
<div class="aspect-w-10 aspect-h-6 overflow-hidden rounded-xl shadow-xl xs:aspect-w-16 xs:aspect-h-7 lg:aspect-none lg:h-full">
<div class="bg-slate-700 h-full">
<img class="object-cover opacity-60 brightness-[40%] grayscale lg:h-full lg:w-full -scale-x-100 " src="${testimonialImage}" alt="">
</div>
</div>
</div>
</div>
<!-- Content Wrapper -->
<div class="flex flex-col justify-center mt-8 xxs:mt-0 xxs:absolute xxs:left-0 xxs:top-0 xxs:h-full xxs:justify-between xxs:pt-8 xxs:pb-12 xxs:px-10 lg:relative lg:justify-start lg:mt-0 lg:left-auto lg:top-auto lg:col-span-2 lg:pl-12">
<p class="mt-2 text-2xl px-4 xxs:px-0 xxs:text-3xl font-semibold tracking-tight text-primaryDark xxs:text-primary sm:font-medium lg:text-primaryDark lg:mt-8 lg:pl-10 xl:mt-16">Our Vision</p>
<div class="mx-auto max-w-md mt-6 px-4 xxs:px-0 xs:max-w-2xl lg:max-w-5xl lg:mt-0 lg:px-0 lg:pt-8 lg:pb-10">
<blockquote>
<div class="relative">
<svg class="absolute -top-6 -left-4 lg:left-0 h-12 w-12 text-white opacity-25 " fill="currentColor" viewBox="0 0 32 32" aria-hidden="true">
<path d="M9.352 4C4.456 7.456 1 13.12 1 19.36c0 5.088 3.072 8.064 6.624 8.064 3.36 0 5.856-2.688 5.856-5.856 0-3.168-2.208-5.472-5.088-5.472-.576 0-1.344.096-1.536.192.48-3.264 3.552-7.104 6.624-9.024L9.352 4zm16.512 0c-4.8 3.456-8.256 9.12-8.256 15.36 0 5.088 3.072 8.064 6.624 8.064 3.264 0 5.856-2.688 5.856-5.856 0-3.168-2.304-5.472-5.184-5.472-.576 0-1.248.096-1.44.192.48-3.264 3.456-7.104 6.528-9.024L25.864 4z" />
</svg>
<p class="mt-2 text-xl text-white lg:pl-10">Lorem ipsum, dolor sit amet consectetur adipisicing elit. Non repudiandae, molestiae perspiciatis nam delectus odit! Id officiis accusantium vel error aut nobis dignissimos, magnam doloribus repellat consequatur minus possimus recusandae quis laborum odit commodi architecto, praesentium natus sunt, dolorem vero enim ipsa illum! Voluptas saepe officiis error assumenda asperiores labore.</p>
</div>
<footer class="mt-6 lg:pl-10">
<p class="text-base font-medium text-white">Dominic Rumsey, 40</p>
<p class="text-base font-medium text-primaryDark xxs:text-primary lg:text-primaryDark">CEO at Sub1</p>
</footer>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
const cards = gsap.utils.toArray(".card");
const cardIcons = gsap.utils.toArray(".card__icon");
// A match media object is kind of like a timeline in that tweens are added to it
const mm = gsap.matchMedia();
mm.add({
sm: "(max-width: 1023px)",
lg: "(min-width: 1024px)"
}, (context) => {
const { sm, lg } = context.conditions;
headerAnimation();
if(lg) cardAnimation();
if(sm) mobileCardAnimation();
});
function headerAnimation() {
const tl = gsap
.timeline({paused:true})
.from(".strapline", {
autoAlpha: 0,
y: 10
})
.from(".header", {
autoAlpha: 0,
y: -10
}, '<.3')
.from(".description", {
autoAlpha: 0
}, '<.3');
ScrollTrigger.create({
trigger: ".strapline",
start: "top 80%",
markers:true,
onEnter: () => tl.play()
});
ScrollTrigger.create({
trigger: '.strapline',
start: "top 110%",
markers:true,
onLeaveBack: () => tl.pause(0)
});
return tl;
}
function cardAnimation() {
tl = gsap
.timeline({paused: true})
.from(cards, {
autoAlpha: 0,
yPercent: 15,
scale: 0.9,
stagger: {
each: 0.3,
ease: "power.in"
}
}, '<-.2');
// Separate scrolltrigger objects allow leaveback and onenter trigger points to be different
ScrollTrigger.create({
trigger: ".card",
start: "top 80%",
// markers:true,
onEnter: () => tl.play()
});
ScrollTrigger.create({
trigger: ".card",
start: "top 110%",
// markers:true,
onLeaveBack: () => tl.pause(0)
});
return tl;
}
function mobileCardAnimation() {
cards.forEach((card, index) => {
const distance = index % 2 === 0 ? -5:5;
const tl = gsap.timeline({paused:true}).from(card, {
autoAlpha: 0,
xPercent: gsap.utils.wrap([distance, -distance, distance]),
});
// Separate scrolltrigger objects allow leaveback and onenter trigger points to be different
ScrollTrigger.create({
trigger: card,
start: "top 80%",
// markers:true,
onEnter: () => tl.play()
});
ScrollTrigger.create({
trigger: card,
start: "top 110%",
// markers:true,
onLeaveBack: () => tl.pause(0)
});
});
}
Also see: Tab Triggers