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.
<div class="header pt-5 flex items-center">
<div class="flex-1 flex justify-around">
<div>Our Products</div>
<div>Process</div>
<div>Our story</div>
</div>
<img src="https://assets.codepen.io/3685267/jack-daniels-logo.svg" alt="" class="h-full" />
<div class="flex-1 flex justify-around">
<div>Recipies</div>
<div>Process</div>
<div>Our Story</div>
</div>
</div>
<div id="app" class="app h-screen w-screen">
<div class="back-text">
<div class="relative w-full h-full">
<div class="absolute flex items-center justify-center inset-0">
<div v-for="cls in clsStatic" :key="cls" :class="['back-text-actual', 'absolute', 'uppercase', `back-text-actual-${cls}`]" v-html="items[cls].name.join(' ')"></div>
</div>
</div>
</div>
<div class="bottle-name-container">
<div class="relative w-full h-full">
<div v-for="cls in clsStatic" :key="cls" :class="['bottle-name', 'font-bold', `bottle-name-${cls}`, 'absolute', 'uppercase']" v-html="items[cls].name.join('<br>')"></div>
</div>
</div>
<div v-for="cls in clsStatic" :key="cls" :class="['bottle', `bottle-${cls}`]">
<img class="h-full" :src="items[cls].bottleImage" alt="..." />
</div>
<div v-for="cls in clsStatic" :key="cls" :class="['description-container', `description-container-${cls}`]">
<div class="description-title font-bold uppercase">
{{items[cls].title[0]}}
</div>
<div class="description-title font-bold uppercase">
{{items[cls].title[1]}}
</div>
<div class="description">{{items[cls].description}}</div>
<button class="btn-read-more">Read more</button>
<div class="video-container">
<img class="w-full" :src="items[cls].video" alt="..." />
</div>
</div>
<div class="nav-container flex items-center">
<button class="arrow p-2">
<img class="h-full" src="https://assets.codepen.io/3685267/jack-daniels-arow-left.svg" alt="prv" />
</button>
<button v-for="(item, index) in bucket" :key="item.id" class="pg-container flex items-center justify-center" :class="[index === bucket[0].id ? 'pg-container-active': '']">
<div class="page"></div>
</button>
<button class="arrow p-2">
<img class="h-full" src="https://assets.codepen.io/3685267/jack-daniels-arow-right.svg" alt="nxt" />
</button>
</div>
</div>
@import url("https://fonts.googleapis.com/css2?family=Libre+Baskerville:ital,wght@0,400;0,700;1,400&family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap");
body {
background: #131313;
color: white;
font-family: "Poppins", sans-serif;
height: 100vh;
overflow: hidden;
}
.header {
height: 100px;
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 100;
}
.back-text {
position: absolute;
width: 50vw;
top: 0;
bottom: 0;
left: 50%;
transform: translate(-50%, 0);
border-left: 1px solid #1c1c1c;
border-right: 1px solid #1c1c1c;
}
.back-text-actual {
color: #1c1c1c;
font-size: 10vw;
font-weight: bold;
white-space: nowrap;
transform: rotate(-90deg) scale(1, 2.5);
-webkit-transform: rotate(-90deg) scale(1, 2.5);
-moz-transform: rotate(-90deg) scale(1, 2.5);
-ms-transform: rotate(-90deg) scale(1, 2.5);
-o-transform: rotate(-90deg) scale(1, 2.5);
font-family: "Libre Baskerville", serif;
}
.bottle {
position: absolute;
bottom: -33vh;
left: 20vw;
height: 120vh;
}
.bottle-name-container {
position: absolute;
left: 5vw;
top: 40vh;
overflow: hidden;
width: 30vw;
height: 30vh;
}
.nav-container {
position: absolute;
left: 5vw;
bottom: 5vh;
}
.description-container {
position: absolute;
right: 10vw;
width: 30vw;
top: 30vh;
}
.bottle-name {
color: #cfc357;
font-family: "Libre Baskerville", serif;
font-size: 4vw;
}
.description-title {
font-size: 2.2vw;
}
.description {
margin-top: 2rem;
font-size: 0.8vw;
}
.btn-read-more {
padding: 1rem;
text-align: center;
width: 10vw;
border: 1px solid #cfc357;
margin-top: 1rem;
font-size: 0.8vw;
}
.video-container {
margin-top: 3rem;
width: 20vw;
margin-left: 10vw;
}
.arrow {
width: 40px;
height: 40px;
border: 2px solid #1c1c1c;
border-radius: 100%;
margin-right: 1rem;
margin-left: 1rem;
}
.pg-container {
width: 16px;
height: 16px;
border-radius: 100%;
margin-right: 0.4rem;
}
.page {
width: 6px;
height: 6px;
border-radius: 100%;
background-color: #444343;
}
.pg-container-active {
border: 1px solid #cfc357;
}
/*
* Nikolay Bondar's Dribble shot
* https://dribbble.com/shots/11746571-Jack-Daniels
*/
const initialItems = [
{
id: 0,
bottleImage: "https://assets.codepen.io/3685267/jack-daniels-b1.png",
name: ["Old No. 7"],
title: ["charcoal mellowed.", "drop by drop"],
description: `Mellowed drop by drop through 10-feet of sugar maple charcol, then matured in handcrafted barrels of our own making, And our Tennesse Whiskey doesn't follow a calendar. It's only ready when our tasters say it is`,
video: "https://assets.codepen.io/3685267/jack-daniels-v1.jpg"
},
{
id: 1,
bottleImage: "https://assets.codepen.io/3685267/jack-daniels-b2.png",
name: ["tennessee", "rye"],
title: ["rye whiskey.", "jack's way."],
description: `Introducing rye whiskey made Jack's way. Crafted with ouur 70-precent rye grain bill, natural spring water from our own Cave Spring Hollow, and Jack's time-honored charcoal mellowing process, Jack Daniel's Tennessee Rye is a whiskey that could only come from Lynchburg, Tennessee.`,
video: "https://assets.codepen.io/3685267/jack-daniels-v2.jpg"
},
{
id: 2,
bottleImage: "https://assets.codepen.io/3685267/jack-daniels-b3.png",
name: ["tennessee", "fire"],
title: ["warm cinnamon.", "exceptionally smooth."],
description: `Sometimes, mixing fire and whiskey is a good thing. Our Tennessee Fire blends warm cinnamon liqueur with the bold character of Jack Daniel's Old No. 7 for a classic spirit with a surprisingly smooth finish`,
video: "https://assets.codepen.io/3685267/jack-daniels-v3.jpg"
}
];
var app = new Vue({
el: "#app",
data: {
clsStatic: ["a", "b"],
clsArray: ["a", "b"],
bucket: initialItems,
items: {
a: initialItems[initialItems.length - 2],
b: initialItems[initialItems.length - 1]
}
},
methods: {
tick: function () {
const [a, b] = this.clsArray;
const tl = gsap.timeline({
onComplete: () => {
const [first, ...rest] = this.bucket;
this.items[a] = first;
this.bucket = [...rest, first];
this.clsArray = [b, a];
this.tick();
}
});
tl.to(`.bottle-name-${a}`, { x: "-100vw", duration: 2 });
tl.to(`.bottle-name-${a}`, { x: "100vw", duration: 0 });
tl.to(`.bottle-name-${b}`, { x: "0vw", duration: 2 }, 0);
tl.to(
`.description-container-${a}`,
{ x: "-10vw", duration: 1, opacity: 0 },
0
);
tl.to(`.description-container-${a}`, { x: "10vw", duration: 0 });
tl.to(
`.description-container-${b}`,
{ x: "0vw", duration: 1, opacity: 1 },
1
);
tl.to(`.back-text-actual-${a}`, { y: "200vh", duration: 2 }, 0);
tl.to(`.back-text-actual-${a}`, { y: "-200vh", duration: 0 });
tl.to(`.back-text-actual-${b}`, { y: "0vh", duration: 2 }, 0);
tl.to(
`.bottle-${a}`,
{ rotation: "-=180", duration: 2, transformOrigin: "50% bottom" },
0
);
tl.to(
`.bottle-${b}`,
{ rotation: "-=180", duration: 2, transformOrigin: "50% bottom" },
0
);
tl.set({}, {}, "+=1");
}
},
mounted: function () {
gsap.to(".bottle-name-b", { x: "100vw", duration: 0 });
gsap.to(".description-container-b", { x: "10vw", duration: 0, opacity: 0 });
gsap.to(".back-text-actual-b", { y: "-200vh", duration: 0 });
gsap.to(".bottle-b", {
rotation: 195,
duration: 0,
transformOrigin: "50% bottom"
});
gsap.to(".bottle-a", {
rotation: 15,
duration: 0,
transformOrigin: "50% bottom"
});
gsap.to({}, { duration: 1.5, onComplete: this.tick });
}
});
Also see: Tab Triggers