How to create Pepsi Card using HTML and CSS

Pepsi Card | Coding Zemigle

Creating visually appealing and interactive elements using only HTML and CSS is a great way to practice front-end web development. In this tutorial, we will walk through the process of creating a Pepsi can-themed card using HTML for structure and CSS for styling. This design will feature a Pepsi can image, along with some engaging details like a title, description, and call-to-action button. Let’s dive in.

To follow this tutorial, you need a basic understanding of HTML and CSS. You’ll also need a code editor like Visual Studio Code and a web browser for testing your creation.

Step 1: Setting Up the HTML Structure

We’ll start by creating the basic HTML layout for the card.

✲    index.html
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Pepsi Can Card | Coding Zemigle</title>
  <link rel="stylesheet" href="style.css">
</head>
<body>
  <div class="card">
    <div class="circle">
      <img src="/images/logo.png" alt="Pepsi Logo" class="logo">
    </div>
    <img src="/images/product.png" alt="Pepsi Can" class="product_img">
    <div class="content">
        <h2>Pepsi Can</h2>
        <p>Pepsi is a cool, refreshing drink that satisfies your thirst and delights your taste buds. Our secret blend of flavors.</p>
      <a href="#">Shop Now</a>
    </div>
  </div>
</body>
</html>



The card div is the outermost container for the card.

Inside it, we have the card-image div which holds the Pepsi can image. The card-content div includes the title, description, and a call-to-action button styled as a link (<a> tag).


Step 2: Writing the CSS

Next, we’ll add CSS to style the card and make it look appealing.

✲    style.css
@import url("https://fonts.googleapis.com/css?family=Verdana:200,300,400,500,600,700,800,900&display=swap");

* {
  margin: 0;
  box-sizing: border-box;
  font-family: "Verdana", sans-serif;
}

body {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: #85CB33;
  --clr: #FFF;
}

.card {
  position: relative;
  width: 350px;
  height: 350px;
  display: flex;
  justify-content: center;
  align-items: center;
  transition: 0.5s;
  transition-delay: 0.5s;
}

.card:hover {
  width: 650px;
  transition-delay: 0.5s;
}

.card .circle {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border-radius: 20px;
  display: flex;
  justify-content: center;
  align-items: center;
}

.card .circle::before {
  content: "";
  position: absolute;
  top: 30;
  left: 2;
  right: 2;
  width: 350px;
  height: 350px;
  border-radius: 50%;
  background: #191919;
  border: 8px solid var(--clr);
  transition: 0.5s, background 0.5s;
  transition-delay: 0.75s, 1s;
}

.card:hover .circle::before {
  transition-delay: 0.5s;
  width: 100%;
  height: 100%;
  border-radius: 20px;
  background: var(--clr);
}

.card .circle .logo {
  position: relative;
  width: 250px;
  transition: 0.5s;
  transition-delay: 0.5s;
}

.card:hover .circle .logo {
  transform: scale(0);
  transition-delay: 0s;
}

.card .product_img {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0) rotate(315deg);
  padding: 10% 0 0 0;
  width: 450px;
  transition: 0.5s ease-in-out;
}

.card:hover .product_img {
  transition-delay: 0.75s;
  top: 25%;
  left: 75%;
  height: 530px;
  transform: translate(-50%, -50%) scale(1) rotate(15deg);
}

.card .content {
  position: absolute;
  width: 50%;
  left: 20%;
  padding: 20px 20px 20px 20px;
  opacity: 0;
  transition: 0.5s;
  visibility: hidden;
}

.card:hover .content {
  transition-delay: 0.75s;
  opacity: 1;
  visibility: visible;
  left: 20px;
}

.card .content h2 {
  color: #222222;
  text-transform: uppercase;
  font-size: 2.5rem;
  line-height: 1em;
}

.card .content p {
  color: #222222;
  padding: 30px 0;
}

.card .content a {
  position: relative;
  color: #FFF;
  background: #85CB33;
  padding: 12px 20px;
  border-radius: 20px;
  display: inline-block;
  text-decoration: none;
  font-weight: 600;
  margin-top: 10px;
}



We reset the default styles with the * selector and set up a minimal and clean environment with a flex-centered body.

The .card class styles the card itself, with a fixed width of 300px, rounded corners, and a shadow effect to make it stand out. The hover effect adds a slight lift when the user hovers over the card.


The .card-image ensures the Pepsi image fills the container proportionally.

Inside the .card-content, the title, description, and button are styled for readability and interaction. The button has a background with hover effects to enhance the user experience.

Conclusion

By following this guide, you’ve successfully created a Pepsi Can Card using just HTML and CSS. This card can be integrated into any website as a promotional item or simply as a cool design feature. Understanding how to create these elements will help you improve your HTML/CSS skills and build more dynamic, visually appealing web pages.

Continue experimenting with different styles and layouts to expand your creativity and knowledge!