Sub topic 5
Comparing with Overlays and Side-by-Side Views
This chapter assumes you can open DevTools and that you have already set up a fair comparison: the same viewport width, zoom level and pixel density for the page and the design. If those differ, every difference you find in this chapter is suspect.
Two ways to compare
An overlay places the design image on top of the built page at partial transparency. A side-by-side view shows the design and the page next to each other at the same scale.
| Method | Good at | Weak at |
|---|---|---|
| Overlay | Position, alignment, edge offsets, element size | Color, font weight, subtle type differences |
| Side-by-side | Overall rhythm, color, hierarchy, missing elements | Differences of a few pixels |
Use both. An overlay finds a heading that sits 6px too low, but it makes color hard to judge because the two layers blend. A side-by-side view shows that a button looks too pale, but it cannot show a 2px offset.
Building an overlay
Export the design frame at the exact width you are testing, at 1x scale. If you test at 1280px, export a 1280px-wide image. Then add it to the page from the DevTools console:
const overlay = document.createElement('img');
overlay.src = 'https://example.com/design-home-1280.png'; // replace with your export
overlay.style.cssText = [
'position:absolute',
'top:0',
'left:0',
'width:1280px',
'opacity:0.5',
'pointer-events:none',
'z-index:99999'
].join(';');
document.body.appendChild(overlay);
// Press "o" to toggle the overlay on and off
document.addEventListener('keydown', (e) => {
if (e.key === 'o') {
overlay.style.display = overlay.style.display === 'none' ? '' : 'none';
}
});pointer-events:none lets you keep clicking and inspecting the page underneath. If the page's Content Security Policy blocks the image, use a browser extension that overlays images instead, or the design tool's own inspect mode.
A workable routine
Toggle the overlay rather than staring at the blended image. Your eye picks up movement between the two states more reliably than it picks up ghosted edges.
Common errors
- Wrong scale. A design exported at 2x and shown at 1x doubles every offset. Check the image's pixel width against the viewport first.
- Scrollbar width. A classic scrollbar takes about 15px of viewport width on some systems, so the page layout shifts against the design. Match the design's frame width to the content area, not the window.
- Anchoring to the wrong edge. Centered layouts need the overlay centered too, or every element looks shifted at wider widths.
- Treating the overlay as the answer. It shows that something differs, not by how much. Confirm each difference with a measurement before you report it.
Exercise
Your overlay shows every element on the page sitting exactly twice as far from the left edge as in the design. What is the most likely cause, and how do you check it?
Show answer
The design image was most likely exported at 2x, or sized wrongly in the overlay. Compare the image's natural pixel width with the viewport width you are testing. If the image is 2560px wide for a 1280px test, re-export at 1x or set the overlay's width to 1280px.