Recommended Free Tools
Set background-attachment: fixed on the element that owns the background. The image is then positioned relative to the viewport instead of moving with the page as it scrolls. For a full-page effect, combine it with an explicit fallback color, centered positioning, no-repeat behavior, and background-size: cover.
The minimal fixed-background CSS
Put the image and attachment rule on the element that should display it. This example keeps the background in place while the document scrolls:
body {
background-image: url("background.jpg");
background-attachment: fixed;
}
Replace background.jpg with a real path to an image your site is authorized to use. The effect is visible only when there is enough content to create scrolling; on a short page, there may be no movement to compare.
A practical full-viewport pattern
Most landing pages need more than the two-property example. This version fills the viewport, avoids tiling, and remains readable if the image fails to load:
#1 Best Overall
- HTML CSS Design and Build Web Sites
- Comes with secure packaging
- It can be a gift option
body {
background-color: #222;
background-image: url("background.jpg");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
}
background-color is the fallback behind the image. Choose a color that still allows the page text to be read. A CSS background is decorative; browsers do not expose background-image as an alternative image to assistive technology. Do not place information that is essential to understanding the page only in the background.
How each CSS value changes the result
| Property or value | What it controls | Typical use |
|---|---|---|
background-attachment: fixed |
Anchors the background to the viewport. It does not move as the page scrolls. | Hero sections or a page-wide visual that stays behind the content. |
background-attachment: scroll |
The initial value. The background is attached to the element and moves as that element moves through the page. | Normal page backgrounds. |
background-attachment: local |
The background moves with the element’s contents when the element itself has scrolling content. | Scrollable panels whose background should follow their text. |
background-size: cover |
Scales the image to fill the box while preserving its aspect ratio. Some edges can be cropped. | Full-bleed visual backgrounds. |
background-size: contain |
Fits the entire image inside the box, preserving its aspect ratio. Empty space can remain. | When seeing the complete image matters more than filling the viewport. |
background-position |
Chooses which part of the image remains visible when it is cropped. | center for a balanced crop, or a focal position such as center top. |
background-repeat |
Controls whether the image tiles. | no-repeat for a single hero image. |
Control cropping with size and position
Use cover for a filled viewport
With cover, the browser enlarges the image until both dimensions cover the element. If the image and viewport have different proportions, the browser crops one dimension. A wide photograph can lose its sides on a tall phone, while a tall image can lose its top and bottom on a desktop monitor.
Use contain to preserve the complete image
contain makes the complete image visible, but it can expose the fallback color around it. This is generally preferable for diagrams, product screenshots, or illustrations where cropping would remove meaning.
Move the focal point
When a subject sits near the top or one side, set its position deliberately:
Free tools Windows power users keep installed
One-click scans. No signup required.
Rank #2
body {
background-color: #222;
background-image: url("mountain.jpg");
background-position: center top;
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
}
Valid positions can use keywords such as left, center, and right, combined with top, center, or bottom. Percentages and lengths give finer control, for example background-position: 60% 30%. Check the crop at every responsive width rather than choosing a position from one desktop screenshot.
Apply the effect to a section instead of the whole page
The same declarations work on a component:
.feature {
min-height: 28rem;
background-color: #1f2933;
background-image: url("feature.jpg");
background-position: center;
background-repeat: no-repeat;
background-size: cover;
background-attachment: fixed;
}
Use a sufficiently tall section or enough surrounding content to make the difference visible. If the element has its own scrolling mechanism, the attachment relationship and the browser’s painting behavior can differ from a page-level background, so test the actual component rather than assuming the body example represents it.
Keep text readable over the image
- Inspect the lightest and darkest areas behind every heading, button, and paragraph.
- Choose a fallback color that preserves legibility before the image loads or if it is blocked.
- Use an overlay when the photograph has uneven detail. A pseudo-element keeps the image decorative while providing a consistent contrast layer.
.hero {
position: relative;
isolation: isolate;
color: white;
background: #222 url("hero.jpg") center / cover no-repeat fixed;
}
.hero::before {
content: "";
position: absolute;
inset: 0;
background: rgb(0 0 0 / 0.38);
z-index: -1;
}
Make sure the section’s content establishes the intended stacking order. Test text against the actual crop at narrow and wide widths; an overlay that looks sufficient on one crop may be too weak on another.
Mobile browsers and responsive fallbacks
background-attachment: fixed has broad desktop browser availability, but a supported value does not guarantee identical scrolling or repaint behavior on every phone. Compatibility data available in 2026 reports partial support in some iOS Safari versions and delayed background-position updates on some mobile devices. The reported global support estimate is 97.26%, with usage context attributed to StatCounter GlobalStats for August 2026; that figure is a dated coverage estimate, not a test of your visitors’ devices.
Rank #3
- Brand: Wiley
- Set of 2 Volumes
- A handy two-book set that uniquely combines related technologies Highly visual format and accessible language makes these books highly effective learning tools Perfect for beginning web designers and front-end developers
Test the browsers, operating systems, orientations, and page lengths that matter to your audience. If the fixed effect is decorative rather than essential, allow normal scrolling on narrow screens:
@media (max-width: 48rem) {
body {
background-attachment: scroll;
}
}
This is a graceful design choice, not a claim that fixed backgrounds are categorically unsupported on mobile. You can also use a regular color or a mobile-specific image if a particular device shows a distracting jump or delayed repaint.
Common problems and fixes
The background does not appear fixed
- No scrollable content: add enough content to create scrolling, then test again.
- Rule is overridden: inspect the element in developer tools and check the computed
background-attachmentvalue. - Wrong element: put the declarations on the element that actually owns the background, not only on a wrapper that has no visible area.
- Image path or response failure: open the image URL directly and check the browser’s network panel. The fallback color should remain visible.
The image is cropped in an unattractive place
Keep cover, then adjust background-position toward the subject. Switch to contain when cropping is unacceptable, and design the surrounding color for the resulting empty space.
Text becomes unreadable
Change the fallback color, reposition the image, or add a translucent overlay. Evaluate contrast across responsive crops, not just the default desktop view.
Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Scan for outdated or missing drivers - takes under a minute3Clear out junk files and repair common Windows errorsRank #4
Scrolling feels wrong on a phone
Confirm the behavior in the target mobile browsers and orientations. If the visual is nonessential, apply the media-query fallback above. A normal scrolling background is usually preferable to a delayed or unstable fixed effect.
A nested scrolling panel behaves unexpectedly
Check whether the background is attached to the panel, its contents, or the page. local is the value designed for a background that follows an element’s scrolling contents; fixed is viewport-relative.
Performance and implementation checks
- Use an appropriately compressed image and dimensions that match the largest display you support; oversized assets increase download time regardless of the attachment value.
- Preview the page with the image disabled to verify that the fallback color and content order still make sense.
- Check keyboard focus, zoom, reduced-motion preferences used by your design system, and contrast on every overlayed control.
- Test long pages as well as short pages; the fixed-versus-scrolling distinction is not apparent without meaningful scroll distance.
- Confirm that the background remains decorative. If an image conveys information, place it in the document as an
<img>with appropriate alternative text instead.
Or skip the browser setup
If you need rendered screenshots of the page rather than a CSS preview, ScreenshotNeo can capture a URL with one request. It accepts consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; those steps can be turned off. Only clean shots are billed, while bot checks or CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing. Each response identifies the result with X-Page-Verdict and X-Billed headers. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for 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 shots; every feature is available on every plan.
Windows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallOutdated Drivers Are Slowing You Down
One free scan finds every outdated or missing driver and matches the right update for your exact hardware.Free scan · exact hardware matchcURL
curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp
Python
import requests
r = requests.get("https://api.screenshotneo.com/v1/shot", params={"access_key": "YOUR_API_KEY", "url": "https://stripe.com"}, timeout=90)
open("shot.webp", "wb").write(r.content)
Node.js
const q = new URLSearchParams({ access_key: 'YOUR_API_KEY', url: 'https://stripe.com' });
const res = await fetch(`https://api.screenshotneo.com/v1/shot?${q}`);
Replace the example URL with your page and follow the parameter details in the ScreenshotNeo documentation. You can control viewport and device settings, wait for a selector or network idle, inject CSS or JavaScript, hide selectors, load lazy images, and choose PNG, JPEG, WebP, or PDF output. When you want repeatable screenshots without maintaining browser automation, sign up for the free ScreenshotNeo plan with no card.
Best Value
FAQ
Does fixed mean the image is fixed to the element?
No. The fixed value anchors the background to the viewport. The scroll value follows the element as it moves through the page, while local follows an element’s scrolling contents.
Can I use a fixed background without background-size: cover?
Yes. Attachment, sizing, position, and repeat are independent properties. Add cover only when you want the image to fill the box, accepting possible cropping.
Should a fixed background contain meaningful content?
No. Background images are presentation. Put essential information in HTML and provide an appropriate alternative when an image is informative.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Frequently Asked Questions
Does fixed mean the image is fixed to the element?
No. The fixed value anchors the background to the viewport; scroll and local describe different attachment relationships.
Can I use a fixed background without background-size: cover?
Yes. Attachment, sizing, position, and repeat are independent properties.
Should a fixed background contain meaningful content?
No. Keep essential information in HTML rather than only in a decorative CSS background.
Quick Recap
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.

