HTML CSS Product Card #2

How to create a simple responsive HTML CSS product card.

Final output:

HTML CSS product card

Final Output Code for Responsive HTML CSS Product Card #2:

HTML

<div class="card-container">
    <div class="card">
        <img class="product-img" src="mocha.png" alt="">
        <div class="card-body">
            <h2>Mocha Latte</h2>
            <div class="rating-container">
                <img src="star.svg" alt="">
                <span>5.0</span>
                <span class="reviews">(180 reviews)</span>
            </div>
            <p class="description">Lorem ipsum dolor sit amet consectetur. Scelerisque urna vel sit dolor fringilla
            </p>
            <div class="card-footer">
                <span class="price">$2.7</span>
                <button><img src="plus.svg" alt=""></button>
            </div>
        </div>
    </div>
</div>

CSS

* {
    margin: 0;
}

body {
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
}

.card-container {

    margin: 3rem;

    .card {
        max-width: 20rem;
        color: #282A3A;
        border-bottom-left-radius: 4rem;
        border-top-right-radius: 4rem;

        .product-img {
            border-bottom-left-radius: 4rem;
            border-top-right-radius: 4rem;
            width: 100%;
        }

        .card-body {
            padding: 1rem 1.5rem;
            display: flex;
            flex-direction: column;
            gap: 1rem;

            h2 {
                font-size: 1.5rem;
                line-height: 1.4;
                font-weight: 600;
            }

            .rating-container {
                align-content: center;
                line-height: 1.2;

                img {
                    margin-right: 4px;
                }

                span:first-of-type {
                    font-size: 1.25rem;
                    font-weight: 700;
                    letter-spacing: 0.4px;
                    opacity: 0.7;
                }

                .reviews {
                    margin-left: .5rem;
                    font-size: 1rem;
                    opacity: 0.72;
                }
            }

            .description {
                font-size: 1rem;
                line-height: 1.4;
                opacity: 0.72;

            }

            .card-footer {
                display: flex;
                justify-content: space-between;
                align-items: center;

                .price {
                    font-size: 1.5rem;
                    font-weight: 700;
                    line-height: 1.2;
                    opacity: 0.7;
                    letter-spacing: 0.4px;
                }

                button {
                    background-color: #6D1600;
                    padding: 0.75rem 2rem;
                    border-radius: 0.5rem;
                    border: none;

                    img {
                        width: 1rem;
                        height: 1rem;
                    }
                }
            }
        }
    }
}

Video tutorial for Responsive HTML CSS Product Card:

If you have any doubts or stuck somewhere, you can reach out through Coding Yaar's Discord server.

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x