Horizontal Product Card for List Views

Efficiently display product information in a compact, horizontal layout with this list view product card.

This design is ideal for secondary display formats like a user-toggled "list view" on a category page, or for layouts where vertical space is at a premium, such as a shopping cart summary.

Screenshot of two horizontal product cards in a list layout.

Get Source Code Preview

About this Component

This component arranges the product image and its corresponding details side-by-side using a Flexbox layout. This horizontal orientation allows for more items to be visible on the screen at once compared to a standard vertical card grid. It also includes a media query to stack the layout vertically on very small screens, ensuring readability on mobile devices.

Features

Code Breakdown

HTML Structure

Each card is an article with the class .hp-card. It's a flex container holding two direct children. The first is a div wrapping the image. The second child is another div which wraps all the textual content and the footer. This simple two-column structure is the foundation of the horizontal layout.

CSS Styling

The main card (.hp-card) is set to display: flex, which places the image and content side-by-side. The content section is itself a flex container with flex-direction: column, allowing us to use flex-grow: 1 on the main info block to push the footer to the bottom. The text-clamping effect on the description (.hp-card-description) is a modern CSS technique that uses the -webkit-line-clamp property to truncate text after a specific number of lines, adding an ellipsis automatically.

A media query at the end of the stylesheet checks for a screen width of 500px or less. When this condition is met, it changes the main card's flex direction to column, effectively stacking the image on top of the content for a better mobile viewing experience.

Code

Here's the complete, self-contained code. It's ready to be used to build a product list or a shopping cart interface.

View Output