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.
<header>
<nav>
<a href="">Home</a>
<a href="">Contacts</a>
<a href="">Info</a>
</nav>
</header>
<!-- carousel -->
<div class="carousel">
<!-- list item -->
<div class="list">
<div class="item">
<img src="https://raw.githubusercontent.com/BuviU/assets-/main/JuicyJoy/bg1.png">
<div class="content">
<div class="author">JuicyJoy</div>
<div class="title">GIN RICKEY</div>
<div class="topic1">COCKTAIL</div>
<div class="des">
<!-- lorem 50 -->
Slime Rickey’s are an all natural green colored update to the classic gin rickey cocktail that are perfect as a Halloween cocktail! Fresh squeezed green grape juice gives this all natural green version of a gin rickey, also called a lime rickey, a tart refreshing flavor and a beautiful light green color. - by Tristin | freshflavorful
</div>
<div class="buttons">
<button>ODER NOW</button>
<button>SEE MORE</button>
</div>
</div>
</div>
<div class="item">
<img src="https://raw.githubusercontent.com/BuviU/assets-/main/JuicyJoy/bg2.png">
<div class="content">
<div class="author">JuicyJoy</div>
<div class="title">ROSÉ WATERMELON</div>
<div class="topic2">MARGARITA</div>
<div class="des">
Spicy Sparkling Watermelon Margaritas made with sparkling rosé wine, fresh watermelon juice and spicy jalapeno infused tequila. This Spicy Rosé Watermelon Margarita has all the elements to make a great cocktail. The fresh, sweet flavor of homemade watermelon juice combined with tart lime and lightly spicy jalapeño infused tequila. Perfect when topped off with a generous pour of sparkling rosé wine. - by Tristin | freshflavorful
</div>
<div class="buttons">
<button>ODER NOW</button>
<button>SEE MORE</button>
</div>
</div>
</div>
<div class="item">
<img src="https://raw.githubusercontent.com/BuviU/assets-/main/JuicyJoy/bg3.png">
<div class="content">
<div class="author">JuicyJoy</div>
<div class="title">COCONUT LEMON</div>
<div class="topic3">PARTY PITCHER</div>
<div class="des">
Coconut Lemon Sour pitcher cocktails are a light and refreshing drink recipe you’ll be whipping up all spring and summer long. A simple, make ahead, large batch cocktail recipe with bright lemonade and coconut water flavor that’s perfect for summer entertaining. - by Tristin | freshflavorful
</div>
<div class="buttons">
<button>ODER NOW</button>
<button>SEE MORE</button>
</div>
</div>
</div>
<div class="item">
<img src="https://raw.githubusercontent.com/BuviU/assets-/main/JuicyJoy/bg4.png">
<div class="content">
<div class="author">JuicyJoy</div>
<div class="title">ORANGE WHITE WINE</div>
<div class="topic4">SPRITZER</div>
<div class="des">
Mandarin Orange White Wine Spritzer is delicious easy wine spritzer with fruit recipe. Perfect as packable picnic cocktail to take along on summer adventures or winter adventures when mandarin oranges are in season. - by Tristin | freshflavorful
</div>
<div class="buttons">
<button>ODER NOW</button>
<button>SEE MORE</button>
</div>
</div>
</div>
<div class="item">
<img src="https://raw.githubusercontent.com/BuviU/assets-/main/JuicyJoy/bg5.png">
<div class="content">
<div class="author">JuicyJoy</div>
<div class="title">CREME DE MENTHE</div>
<div class="topic5">FRAPPE</div>
<div class="des">
This one is made with only one liquid – the Crème de Menthe. Only one liquor means you’ve got a drink that’s pretty easy to make. The only thing you have to do is crush the ice, pile that crushed ice high and pour the Crème de Menthe on top. By the time you’re finished it should look like a pretty alcoholic snow cone. There’s just one problem with this cocktail – it’s pretty strong. It kinda tastes like mouth wash. Now, that’s not to say it’s not worth a sip or two, but I’d taste this cocktail and then move on to something better. - by Jennifer | kitchycooking
</div>
<div class="buttons">
<button>ODER NOW</button>
<button>SEE MORE</button>
</div>
</div>
</div>
<div class="item">
<img src="https://raw.githubusercontent.com/BuviU/assets-/main/JuicyJoy/bg7.png">
<div class="content">
<div class="author">JuicyJoy</div>
<div class="title">BLUEBERRY SWITCHEL</div>
<div class="topic7">SPRITZER</div>
<div class="des">
Spiked Blueberry Switchel Spritzer is a refreshing, fruity and fizzy way to get your drinking vinegar fix! Spiced rum pairs perfectly with the warm ginger and bright blueberry flavors, but leave it out and this delicious switchel cocktail becomes an equally invigorating mocktail! - by Tristin | freshflavorful
</div>
<div class="buttons">
<button>ODER NOW</button>
<button>SEE MORE</button>
</div>
</div>
</div>
</div>
<!-- list thumnail -->
<div class="thumbnail">
<div class="item">
<img src="https://raw.githubusercontent.com/BuviU/assets-/main/JuicyJoy/1.png">
<div class="content">
<div class="title">
GIN RICKEY
</div>
<div class="description">
COCKTAIL
</div>
</div>
</div>
<div class="item">
<img src="https://raw.githubusercontent.com/BuviU/assets-/main/JuicyJoy/2.png">
<div class="content">
<div class="title">
ROSÉ WATERMELON
</div>
<div class="description">
MARGARITA
</div>
</div>
</div>
<div class="item">
<img src="https://raw.githubusercontent.com/BuviU/assets-/main/JuicyJoy/3.png">
<div class="content">
<div class="title">
COCONUT LEMON
</div>
<div class="description">
PARTY PITCHER
</div>
</div>
</div>
<div class="item">
<img src="https://raw.githubusercontent.com/BuviU/assets-/main/JuicyJoy/4.png">
<div class="content">
<div class="title">
ORANGE WHITE WINE
</div>
<div class="description">
SPRITZER
</div>
</div>
</div>
<div class="item">
<img src="https://raw.githubusercontent.com/BuviU/assets-/main/JuicyJoy/5.png">
<div class="content">
<div class="title">
CREME DE MENTHE
</div>
<div class="description">
FRAPPE
</div>
</div>
</div>
<div class="item">
<img src="https://raw.githubusercontent.com/BuviU/assets-/main/JuicyJoy/7.png">
<div class="content">
<div class="title">
BLUEBERRY SWITCHEL
</div>
<div class="description">
SPRITZER
</div>
</div>
</div>
</div>
<!-- next prev -->
<div class="arrows">
<button id="prev"><</button>
<button id="next">></button>
</div>
<!-- time running -->
<div class="time"></div>
</div>
</body>
@import url('https://fonts.googleapis.com/css2?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{
margin: 0;
background-color: #000;
color: #eee;
font-family: Poppins;
font-size: 15px;
}
.des{
width: 60%;
}
a{
text-decoration: none;
}
header{
width: 1140px;
max-width: 80%;
margin: auto;
height: 50px;
display: flex;
align-items: center;
position: relative;
z-index: 100;
}
header a{
color: #eee;
margin-right: 40px;
}
/* carousel */
.carousel{
height: 100vh;
margin-top: -50px;
width: 100vw;
overflow: hidden;
position: relative;
}
.carousel .list .item{
width: 100%;
height: 100%;
position: absolute;
inset: 0 0 0 0;
}
.carousel .list .item img{
width: 100%;
height: 100%;
object-fit: cover;
}
.carousel .list .item .content{
position: absolute;
top: 20%;
width: 1140px;
max-width: 80%;
left: 50%;
transform: translateX(-50%);
padding-right: 30%;
box-sizing: border-box;
color: #fff;
text-shadow: 0 5px 10px #0004;
}
.carousel .list .item .author{
font-weight: bold;
letter-spacing: 10px;
}
.carousel .list .item .title,
.carousel .list .item .topic1, .topic2 , .topic3, .topic4, .topic5, .topic7{
font-size: 4.3em;
font-weight: bold;
line-height: 1.3em;
}
.carousel .list .item .topic1{
color: #48990e;
}
.carousel .list .item .topic2{
color: #eb0203;
}
.carousel .list .item .topic3{
color: #ebbe08;
}
.carousel .list .item .topic4{
color: #f53400;
}
.carousel .list .item .topic5{
color: #1fcba0;
}
.carousel .list .item .topic7{
color: #a70da7;
}
.carousel .list .item .buttons{
display: grid;
grid-template-columns: repeat(2, 130px);
grid-template-rows: 40px;
gap: 5px;
margin-top: 20px;
}
.carousel .list .item .buttons button{
border: none;
background-color: #eee;
letter-spacing: 3px;
font-family: Poppins;
font-weight: 500;
}
.carousel .list .item .buttons button:nth-child(2){
background-color: transparent;
border: 1px solid #fff;
color: #eee;
}
/* thumbail */
.thumbnail{
position: absolute;
bottom: 50px;
left: 60%;
width: max-content;
z-index: 100;
display: flex;
gap: 20px;
}
.thumbnail .item{
width: 150px;
height: 220px;
flex-shrink: 0;
position: relative;
}
.thumbnail .item img{
width: 100%;
height: 100%;
object-fit: cover;
border-radius: 20px;
}
.thumbnail .item .content{
color: #fff;
position: absolute;
bottom: 10px;
left: 10px;
right: 10px;
}
.thumbnail .item .content .title{
font-weight: 500;
}
.thumbnail .item .content .description{
font-weight: 300;
}
/* arrows */
.arrows{
position: absolute;
top: 90%;
right: 52%;
z-index: 100;
width: 300px;
max-width: 30%;
display: flex;
gap: 10px;
align-items: center;
}
.arrows button{
width: 40px;
height: 40px;
border-radius: 50%;
background-color: #eee4;
border: none;
color: #fff;
font-family: monospace;
font-weight: bold;
transition: .5s;
}
.arrows button:hover{
background-color: #fff;
color: #000;
}
/* animation */
.carousel .list .item:nth-child(1){
z-index: 1;
}
/* animation text in first item */
.carousel .list .item:nth-child(1) .content .author,
.carousel .list .item:nth-child(1) .content .title,
.carousel .list .item:nth-child(1) .content .topic,
.carousel .list .item:nth-child(1) .content .des,
.carousel .list .item:nth-child(1) .content .buttons
{
transform: translateY(50px);
filter: blur(20px);
opacity: 0;
animation: showContent .5s 1s linear 1 forwards;
}
@keyframes showContent{
to{
transform: translateY(0px);
filter: blur(0px);
opacity: 1;
}
}
.carousel .list .item:nth-child(1) .content .title{
animation-delay: 1.2s!important;
}
.carousel .list .item:nth-child(1) .content .topic{
animation-delay: 1.4s!important;
}
.carousel .list .item:nth-child(1) .content .des{
animation-delay: 1.6s!important;
}
.carousel .list .item:nth-child(1) .content .buttons{
animation-delay: 1.8s!important;
}
/* create animation when next click */
.carousel.next .list .item:nth-child(1) img{
width: 150px;
height: 220px;
position: absolute;
bottom: 50px;
left: 50%;
border-radius: 30px;
animation: showImage .5s linear 1 forwards;
}
@keyframes showImage{
to{
bottom: 0;
left: 0;
width: 100%;
height: 100%;
border-radius: 0;
}
}
.carousel.next .thumbnail .item:nth-last-child(1){
overflow: hidden;
animation: showThumbnail .5s linear 1 forwards;
}
.carousel.prev .list .item img{
z-index: 100;
}
@keyframes showThumbnail{
from{
width: 0;
opacity: 0;
}
}
.carousel.next .thumbnail{
animation: effectNext .5s linear 1 forwards;
}
@keyframes effectNext{
from{
transform: translateX(150px);
}
}
/* running time */
.carousel .time{
position: absolute;
z-index: 1000;
width: 0%;
height: 3px;
background-color: #f1683a;
left: 0;
top: 0;
}
.carousel.next .time,
.carousel.prev .time{
animation: runningTime 3s linear 1 forwards;
}
@keyframes runningTime{
from{ width: 100%}
to{width: 0}
}
/* prev click */
.carousel.prev .list .item:nth-child(2){
z-index: 2;
}
.carousel.prev .list .item:nth-child(2) img{
animation: outFrame 0.5s linear 1 forwards;
position: absolute;
bottom: 0;
left: 0;
}
@keyframes outFrame{
to{
width: 150px;
height: 220px;
bottom: 50px;
left: 50%;
border-radius: 20px;
}
}
.carousel.prev .thumbnail .item:nth-child(1){
overflow: hidden;
opacity: 0;
animation: showThumbnail .5s linear 1 forwards;
}
.carousel.next .arrows button,
.carousel.prev .arrows button{
pointer-events: none;
}
.carousel.prev .list .item:nth-child(2) .content .author,
.carousel.prev .list .item:nth-child(2) .content .title,
.carousel.prev .list .item:nth-child(2) .content .topic,
.carousel.prev .list .item:nth-child(2) .content .des,
.carousel.prev .list .item:nth-child(2) .content .buttons
{
animation: contentOut 1.5s linear 1 forwards!important;
}
@keyframes contentOut{
to{
transform: translateY(-150px);
filter: blur(20px);
opacity: 0;
}
}
@media screen and (max-width: 678px) {
.carousel .list .item .content{
padding-right: 0;
}
.carousel .list .item .content .title{
font-size: 30px;
}
}
//step 1: get DOM
let nextDom = document.getElementById('next');
let prevDom = document.getElementById('prev');
let carouselDom = document.querySelector('.carousel');
let SliderDom = carouselDom.querySelector('.carousel .list');
let thumbnailBorderDom = document.querySelector('.carousel .thumbnail');
let thumbnailItemsDom = thumbnailBorderDom.querySelectorAll('.item');
let timeDom = document.querySelector('.carousel .time');
thumbnailBorderDom.appendChild(thumbnailItemsDom[0]);
let timeRunning = 3000;
let timeAutoNext = 7000;
nextDom.onclick = function(){
showSlider('next');
}
prevDom.onclick = function(){
showSlider('prev');
}
let runTimeOut;
let runNextAuto = setTimeout(() => {
next.click();
}, timeAutoNext)
function showSlider(type){
let SliderItemsDom = SliderDom.querySelectorAll('.carousel .list .item');
let thumbnailItemsDom = document.querySelectorAll('.carousel .thumbnail .item');
if(type === 'next'){
SliderDom.appendChild(SliderItemsDom[0]);
thumbnailBorderDom.appendChild(thumbnailItemsDom[0]);
carouselDom.classList.add('next');
}else{
SliderDom.prepend(SliderItemsDom[SliderItemsDom.length - 1]);
thumbnailBorderDom.prepend(thumbnailItemsDom[thumbnailItemsDom.length - 1]);
carouselDom.classList.add('prev');
}
clearTimeout(runTimeOut);
runTimeOut = setTimeout(() => {
carouselDom.classList.remove('next');
carouselDom.classList.remove('prev');
}, timeRunning);
clearTimeout(runNextAuto);
runNextAuto = setTimeout(() => {
next.click();
}, timeAutoNext)
}
Also see: Tab Triggers