โ† Back to Blog

How to Resize Background Images for Any Screen

2026-04-20 ยท 5 min read

The Challenge of Background Image Adaptation

Background images must display correctly on an enormously diverse range of screens: from 320px-wide older phones to 2560px-wide 4K monitors, from landscape desktop browsers to portrait mobile screens, from standard-DPI screens to Retina high-DPI screens. Providing only one fixed-size image can mean very different results across devices.

There are two approaches to solving this: preparing the correct original image size (typically a wide enough landscape image), and using the correct CSS background-size property to control display behavior. Combining both is needed for optimal results across all devices.

Key rule: the actual pixel width of a background image should be at least 1ร— the maximum display width (for non-Retina screens) or 2ร— (for Retina screens). Providing a 2560px-wide image safely covers most users' screen needs.

CSS background-size Property Explained

CSS's background-size property controls how a background image displays in its container. Key values:

Complete CSS for Full-Screen Background Images

For a full-screen background that doesn't distort, has no gaps, and displays correctly on all screen sizes, use this recommended CSS:

.hero-section {
  background-image: url('background.webp');
  background-size: cover;
  background-position: center center;
  background-repeat: no-repeat;
  background-attachment: fixed; /* Parallax effect (disable on mobile) */
  min-height: 100vh;
}

background-position: center center ensures the center of the image is preserved when cropping; background-repeat: no-repeat prevents the image from tiling at the edges; background-attachment: fixed creates a parallax scrolling effect, but performs poorly on mobile โ€” disable it on mobile via media queries.

Mobile Background Image Optimization

Mobile screens are typically portrait-oriented while most background images are landscape. With background-size: cover, a landscape background gets significantly cropped on a portrait phone screen, potentially covering key content.

Solution: use media queries to provide a portrait-optimized background image specifically for mobile, or adjust background-position to ensure key content areas aren't cropped:

/* Desktop: landscape background */
.hero { background-image: url('bg-desktop.webp'); }

/* Mobile: portrait background */
@media (max-width: 768px) {
  .hero {
    background-image: url('bg-mobile.webp');
    background-position: top center;
  }
}

How to Resize Background Images to Avoid Key Content Cutoff

When resizing background images, you need to anticipate the crop areas on different screens. With background-size: cover, cropping starts from the sides (wide screens) or top/bottom (narrow screens), preserving the center by default.

If the background image has specific key content (text, logo), place it in the center of the image (the safe zone) to ensure it's visible at all screen ratios. Before resizing, use a crop tool to simulate different ratio displays and confirm key content remains visible under all cropping scenarios.

Performance: Avoiding Background Images as a Bottleneck

Background images are an important factor in page load speed. Best practices: use WebP format (30% smaller than JPG); lazy-load non-critical background images (use JavaScript to dynamically set background URLs when elements enter the viewport); provide multiple resolution versions loaded via media queries; use <link rel="preload"> for hero background images to preload early and improve LCP.

Important note: background images declared in CSS are not picked up by the browser's preload scanner โ€” they load later than <img> tags. If a background image is the page's LCP element, strongly consider switching to an <img> tag with absolute positioning to achieve the visual background effect, allowing the browser's preload optimization to apply.

Try the free tool now

Use Free Tool โ†’