ℹ️ Select 'Choose Exercise', or randomize 'Next Random Exercise' in selected language.

Choose Exercise:
Timer 00:00
WPM --
Score --
Acc --
Correct chars --

Product Card Design - Image Zoom on Hover

CSS

Goal -- WPM

Ready
Exercise Algorithm Area
1/* Base styles for the product card */
2.product-card {
3border: 1px solid #ddd;
4border-radius: 8px;
5overflow: hidden;
6width: 300px;
7margin: 20px;
8box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
9transition: transform 0.3s ease-in-out;
10}
11
12.product-card:hover {
13transform: translateY(-5px);
14}
15
16.product-image-container {
17width: 100%;
18height: 200px;
19overflow: hidden;
20position: relative;
21}
22
23.product-image {
24width: 100%;
25height: 100%;
26object-fit: cover;
27transition: transform 0.3s ease-in-out;
28}
29
30.product-card:hover .product-image {
31transform: scale(1.05);
32}
33
34.product-info {
35padding: 15px;
36}
37
38.product-title {
39font-size: 1.2em;
40margin-bottom: 10px;
41color: #333;
42}
43
44.product-price {
45font-size: 1.1em;
46color: #007bff;
47font-weight: bold;
48}
49
50/* Edge case: ensure no overflow on very small cards */
51@media (max-width: 320px) {
52.product-card {
53width: 90%;
54margin: 10px auto;
55}
56}
Algorithm description viewbox

Product Card Design - Image Zoom on Hover

Algorithm description:

This CSS code styles a product card with an image, title, and price. It includes a hover effect where the entire card slightly lifts and the product image zooms in. This enhances user engagement by providing visual feedback when interacting with a product listing. It's commonly used in e-commerce websites and online catalogs.

Algorithm explanation:

The CSS utilizes `box-shadow`, `border-radius`, and `overflow: hidden` to create a visually appealing card. The `transition` property is applied to both the `.product-card` and `.product-image` for smooth animations. On hover, `.product-card` translates upwards (`translateY(-5px)`) and `.product-image` scales up (`scale(1.05)`). The `object-fit: cover` ensures the image maintains its aspect ratio and covers the container. An edge case is handled for very small screens to prevent the card from becoming too narrow and potentially overflowing its content. The combination of these properties creates an interactive and polished product display.

Pseudocode:

Define base styles for the product card container.
Apply border, rounded corners, and shadow.
Set a fixed width and margin.
Add a transition for transform.
On card hover:
  Apply a slight upward translation.
Define styles for the image container.
Ensure image covers the container and hides overflow.
Add a transition for transform to the image.
On card hover:
  Scale the image up slightly.
Define styles for product information section.
Style the product title and price.