Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

To make card images the same size without distorting them, give each image a consistent display box and set object-fit: cover. This fills the box while preserving the photo’s proportions, cropping the edges when its shape differs from the box. Use contain instead when the whole image must remain visible, and use an <img> with appropriate alternative text when the image conveys information.

Build a card image that stays consistent

Card layouts often combine images with different source dimensions and proportions. If each image is allowed to determine its own height, the cards can look uneven. If an image is forced into a different shape without preserving its proportions, it can look stretched. The reliable fix is to decide the shape of the image area first, then choose how the source image should fit inside it.

For meaningful content, start with an HTML <img>. The following example uses a fixed-height image row and a responsive grid of cards. The 200px height is an example, not a universal recommendation; choose a value that suits your design and content.

<div class="cards">
  <article class="card">
    <h2>A quiet morning</h2>
    <img src="morning.jpg" alt="Sunlight falling across a kitchen table">
    <div class="content">A short description of the story.</div>
  </article>

  <article class="card">
    <h2>A walk in the park</h2>
    <img src="park.jpg" alt="A tree-lined path through the park">
    <div class="content">Another short description.</div>
  </article>
</div>
.cards {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 20px;
}

.card {
  display: grid;
  grid-template-rows: max-content 200px 1fr;
}

.card img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

This follows the card layout pattern documented by MDN: a responsive grid arranges cards, and a grid within each card gives the image a consistent row. width: 100% and height: 100% make the image fill that row; object-fit controls how its pixels are placed in the available space. display: block avoids the small baseline gap that inline images can leave below themselves.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

The card’s row sizing also affects the result. Here the first row accommodates the heading, the second is the fixed image area, and the final row receives the remaining content. If your card’s markup differs, adapt the row definition to match its actual children rather than copying the row count blindly.

Choose a fixed height or a responsive aspect ratio

A fixed image-row height is useful when the card design needs the same image height at every grid width. It keeps the visual rhythm steady, but a narrow card can then show a relatively shallow or tall crop depending on its proportions.

If the image should scale proportionally with the card’s width, use an aspect ratio instead. For example, a 16:9 frame becomes wider as its container does, without requiring a fixed pixel height:

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
.card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
}

When the ratio is placed on the image itself, the browser uses it to size the image box. In a more complex layout, you can put the ratio on a wrapper and size the image to fill the wrapper. This can be useful if the frame also needs a background color, clipping, or other styling:

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
.card-image {
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #eee;
}

.card-image img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

Choose a ratio based on the content and layout rather than assuming every card needs the same one. A landscape ratio may work well for editorial thumbnails; a square or portrait frame may suit other content. Whatever you choose, applying one rule consistently to the image area makes a collection easier to scan.

Use cover or contain based on what must remain visible

object-fit: cover preserves the image’s source proportions and fills the entire frame. If the source and frame have different aspect ratios, some of the image falls outside the frame and is cropped. It is often a good choice for photos where a full-bleed appearance matters more than showing every edge.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

object-fit: contain also preserves the source proportions, but scales the whole image until it fits inside the frame. If the ratios differ, unused space can remain on two sides. Use it when clipping any part of the image would remove important information—for example, a product diagram or graphic that needs to be seen in full. The surrounding space is not a failure; it is the trade-off for keeping the entire source visible.

Avoid object-fit: fill when the frame and source have different proportions. It stretches the image to match both dimensions, which can distort faces, objects, and text in the image. If a source already has the exact proportions you want, fill may not visibly distort it, but cover or contain makes the intended behavior clearer.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Position the crop around the important subject

With cover, the default centered crop may not keep the subject in view. Adjust object-position to choose which part of the image should stay prominent:

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft
.card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 65% center;
}

object-position accepts position values such as center, top, or percentages. A value such as 65% center shifts the alignment toward a different horizontal part of the image. Try the crop at the actual card sizes in your layout: a subject that is well placed in a wide card may shift out of the visible area in a narrow one.

If the image changes depending on the card or viewport, set a more specific class for the image that needs a different crop, rather than changing every card’s alignment. For instance:

.card img {
  object-fit: cover;
  object-position: center;
}

.card img.portrait-subject {
  object-position: 70% center;
}

Use an image element for content and a background for decoration

Use an <img> when the image communicates something the reader needs to know. Write alternative text that conveys the image’s purpose in context; it should not merely repeat the filename or say “image.” If the image is purely decorative and adds no information, an empty alt attribute (alt="") keeps it from being announced as meaningful content.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

A CSS background is convenient for decoration, layering, or a visual treatment behind other content. However, assistive technology does not receive special information from CSS background images. Do not put essential information only in a background image. If a decorative background might fail to load, set a fallback color, and make sure any text over the image remains readable:

.card-banner {
  color: #fff;
  background-color: #404040;
  background-image: url("banner.jpg");
  background-position: center;
  background-size: cover;
}

Here the fallback color appears if the image is unavailable. The text color and image should be checked together so that the foreground remains legible across the image’s likely appearance.

Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Check the result across card widths

A responsive grid changes each card’s width as the available space changes. MDN’s example uses repeat(auto-fill, minmax(230px, 1fr)) with a 20px gap; those values are a starting point to adapt, not requirements. The minimum width determines when another column can fit, while the gap sets space between cards. Check the design at the narrow and wide sizes your page supports, especially when cropping photos with subjects near an edge.

For a useful visual review, compare the same cards at multiple grid widths and look for inconsistent frame heights, subjects cropped out, or content that is not legible. If a particular source image needs a special crop, adjust its position. If many sources lose important details under cover, consider contain or a different frame ratio.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshoot common card-image problems

  • The image looks stretched. Confirm that the frame has a defined height or aspect ratio, then use cover or contain. A mismatch between the source and frame with fill can distort the source.
  • The crop cuts off the subject. Cropping is expected with cover when the ratios differ. Change object-position to move the visible region, or use contain if all of the image is necessary.
  • Image areas or card rows are different heights. Give the image area a shared fixed row height or aspect ratio and verify the card’s grid rows match its markup. The image needs to fill that defined area.
  • The image appears too short or too tall at some widths. Decide whether the design calls for a fixed height or a proportional frame. A fixed row holds its height as width changes; an aspect ratio scales with width.
  • A screen reader misses meaningful imagery. Put informative imagery in an <img> element and provide purpose-appropriate alternative text instead of relying on a CSS background.
  • Text becomes hard to read over a background image. Add a fallback background color and check foreground contrast against the image; do not assume the image will always load or have the same visual content.

Or skip the browser setup

If you have already built the card page and want a screenshot of its rendered result, ScreenshotNeo can return an image or PDF with one GET request. It captures a page; it does not replace the CSS work above. For example, this cURL request saves a WebP screenshot of a page. Replace the example URL with your publicly reachable page URL; see the ScreenshotNeo API documentation for request options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
  • Cookie and consent banners are accepted before capture, and 60+ known consent platforms, newsletter popups, and chat widgets can be removed; each of these steps can be turned off.
  • Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing. Responses include X-Page-Verdict and X-Billed headers.
  • An MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents, including Claude, Cursor, and other MCP clients.
  • The Free plan includes 1,000 screenshots per month with no card; paid plans start at $5 for 3,000 screenshots.

Sign up for ScreenshotNeo’s free plan to try it with 1,000 screenshots a month and no card.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.