Open In App

Create a Product Detail Page Template using HTML and CSS

Last Updated : 20 Dec, 2023
Improve
Improve
Like Article
Like
Save
Share
Report

In this article, we will create a Product Details Layout Template using HTML & CSS. This Card is generally used in e-commerce websites to make the product more presentable and show details clearly. The card-like structure includes details such as product name, price, and a concise description, presented in a clean and visually appealing format. The layout incorporates subtle hover effects for enhanced user interaction, providing a polished and responsive product display.

Preview

productsnap-(1)

Preview

Approach

  • Create a basic card structure using HTML. Use <img> element to show the product image and <div> element to show the details.
  • The card layout within the container includes an image, course information, and a description. Make the three same card layouts with different course names, and respective details.
  • With the help of class and id give style to the element inside <style> element in the head section of the HTML file.
  • To give the Animation effect we have used transition and transform properties whenever the user hovers the Card.

Example: The below example shows how to Create a Product Details layout template using HTML & CSS.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8">
    <meta name="viewport" 
          content="width=device-width,
                   initial-scale=1.0">
    <title>
        Product Details layout template
    </title>
    <link rel="stylesheet"
          href="style.css">
</head>
  
<body>
    <div class="container_box">
  
        <!-- Card 1 -->
        <div class="container">
            <div>
                <img src=
                    alt="GeeksforGeeksImage">
                <div>
                      <span class="response">
                        40k+ interested Geeks
                    </span>
                    <span class="ratings">
                        Ratings: 5.0
                    </span>
                </div>
            </div>
            <div class="info front cardutility">
                <div class="course-title">
                    Web Design Course
                </div>
                <div class="des cardutility">
                    <div>
                        Complete guidance from
                        Biggner to Advance
                    </div>
                    <div>
                        Price:
                        <span class="rates">Rs.7000</span>
                        <span class="explore_link">
                            <a href="#" 
                               class="link_a">
                                Explore
                            </a>
                        </span>
                    </div>
                </div>
            </div>
        </div>
  
        <!-- Card 2 -->
        <div class="container">
            <div>
                <img src=
                    alt="GeeksforGeeksImage">
                <div>
                    <span class="response">
                        70k+ interested Geeks
                    </span>
                    <span class="ratings">
                        Ratings: 5.0
                    </span>
                </div>
            </div>
            <div class="info front cardutility">
                <div class="course-title">
                    Full Stack Course
                </div>
                <div class="des cardutility">
                    <div>
                        Complete guidance
                        from Biggner to Advance
                    </div>
                    <div>
                        Price:
                        <span class="rates">
                            Rs.9000
                        </span>
                        <span class="explore_link">
                            <a href="#" 
                               class="link_a">
                                Explore
                            </a>
                        </span>
                    </div>
                </div>
            </div>
        </div>
  
        <!-- Card 3 -->
        <div class="container">
            <div>
                <img src=
                     alt="GeeksforGeeksImage">
                <div>
                      <span class="response">
                        20k+ interested Geeks
                    </span>
                    <span class="ratings">
                        Ratings: 5.0
                    </span>
                </div>
            </div>
            <div class="info front cardutility">
                <div class="course-title">
                    DSA JAVA and C++ Course
                </div>
                <div class="des cardutility">
                    <div>
                        Complete guidance
                        from Biggner to Advance
                    </div>
                    <div>
                        Price:
                        <span class="rates">Rs.5000 </span>
                        <span class="explore_link">
                            <a href="#" class="link_a">
                                Explore
                            </a>
                        </span>
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
  
</html>


CSS




/* style.css*/
body {
    background-color: rgb(165, 192, 201);
    justify-content: center;
    align-items: center;
    display: flex;
    color: rgb(239, 238, 220);
}
  
.container {
    height: 414px;
    width: 368px;
    background-color: rgb(20, 21, 82);
    border: 2px solid white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    border-radius: 15px;
    box-shadow: rgba(41, 40, 40, 0.2);
    gap: 30px;
    transition: transform 0.2s ease-in-out;
}
  
.container_box {
    display: flex;
    height: 800px;
    justify-content: center;
    align-items: center;
    gap: 2vw;
    flex-wrap: wrap;
    margin-top: 20px;
}
  
.container:hover {
    transform: scale(1.1);
}
  
.cardutility {
    height: 80px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 10px;
    font-size: 20px;
    border-radius: 10px;
}
  
.des {
    text-align: center;
    padding: 5px;
    margin: 1px;
    border-radius: 10px;
    text-justify: auto;
}
  
.spaceicon {
    gap: 10px;
}
  
#btnid {
    border-radius: 100%;
    height: 50px;
    width: 50px;
    position: relative;
}
  
img {
    width: 340px;
    height: 230px;
    border-radius: 10px;
    border: 5px solid white;
}
  
.course-title {
    font-size: 25px;
}
  
.response {
    margin-left: 20px;
}
  
.ratings {
    margin: 15px 0 0 80px;
    padding: 3px;
}
  
.rates {
    margin-left: 3px;
}
  
.explore_link {
    border: 1px solid white;
    border-radius: 5px;
    margin: 2px 0 0 70px;
    background-color: aliceblue;
}
  
.link_a {
    color: rgb(0, 0, 0);
    text-decoration: none;
}
  
@media only screen and (max-width: 376px) {
    body {
        background-color: rgb(99, 176, 201);
    }
  
    .container {
        height: 300px;
        width: 300px;
        border-radius: 5px;
        gap: 10px;
    }
  
    img {
        width: 240px;
        height: 130px;
        border-radius: 10px;
        border: 5px solid white;
        margin-left: 25px;
    }
  
    .response {
        margin-left: 10px;
    }
  
    .ratings {
        margin: 5px 0 0 50px;
        padding: 3px;
    }
  
    .course-title {
        font-size: 10px;
    }
}


Output:

productcardgif

 



Like Article
Suggest improvement
Share your thoughts in the comments

Similar Reads