You open the contact page on your phone and the whole page wobbles left and right. There's a thin strip of white on the right edge. Something is wider than the screen.
Nine times out of ten, it's the map.
Before: the pasted embed
Google Maps' "Embed a map" button gives you this:
<iframe
src="https://www.google.com/maps/embed?pb=..."
width="600"
height="450"
style="border:0;"
allowfullscreen=""
loading="lazy"
referrerpolicy="no-referrer-when-downgrade">
</iframe>width="600" is a fixed pixel width. An iPhone screen is about 390px wide. The iframe stays at 600px, pushes past the edge of the screen, and the whole document gets a horizontal scrollbar.
How to find the culprit: in DevTools, run this in the console:
[...document.querySelectorAll('*')].filter(el => el.scrollWidth > document.documentElement.clientWidth)The deepest element in the list is usually the cause.
After: two lines of CSS
<iframe
class="map-embed"
src="https://www.google.com/maps/embed?pb=..."
title="Map to Neue Tiger Studio, Ann Arbor"
loading="lazy"
referrerpolicy="no-referrer-when-downgrade"
allowfullscreen>
</iframe>.map-embed {
width: 100%;
aspect-ratio: 4 / 3;
border: 0;
}width: 100%makes the map fit its container instead of forcing 600px.aspect-ratiokeeps the height in proportion, so you don't end up with a tall, skinny strip on mobile. Every evergreen browser supports it.titleisn't optional. Screen readers announce iframes by title, and without one, users hear "frame" with no context.
We dropped the width and height attributes because the CSS now does that job. If you want to keep them as a fallback, CSS overrides them, so that's fine too.
In Astro
Wrap it once and stop pasting raw embeds:
---
// src/components/MapEmbed.astro
interface Props { src: string; title: string; ratio?: string }
const { src, title, ratio = '4 / 3' } = Astro.props;
---
<iframe
class="map-embed"
src={src}
title={title}
loading="lazy"
referrerpolicy="no-referrer-when-downgrade"
allowfullscreen
style={`aspect-ratio: ${ratio}`}
></iframe>
<style>
.map-embed { width: 100%; border: 0; }
</style>So what are Chrome 154's "responsive iframes"?
Chrome 154 adds a new CSS property, frame-sizing, that lets an iframe size itself to the content inside it. It solves a different problem than the map does, and it's worth knowing about.
The map problem is about width: the iframe is wider than its container. frame-sizing is about height: an embed whose content is taller or shorter than the box you guessed. Think comment threads, forms, booking widgets, or your own "latest posts" embed. Until now, you either hard-coded a height and lived with the scrollbar or the gap, or you wired up postMessage and a resize script.
With frame-sizing, the parent page does this:
.embed {
width: 100%;
frame-sizing: content-height;
}and the embedded page opts in:
<meta name="responsive-embedded-sizing" content="allow-origins=https://your-site.example">If the embedded content changes after it loads, for example when a "load more" button adds items, the embedded page calls window.requestResize().
The catches
- It's behind a flag in Chrome 154 (and Edge). Firefox and Safari don't support it yet, so treat it as progressive enhancement.
- The embedded page has to opt in. You can't add that meta tag to Google Maps, YouTube or a third-party booking widget. Only the site serving the embed can. That's why this won't fix your map.
- It can cause layout shift. The iframe content loads after your page, so the box can resize after first paint. Avoid it for embeds above the fold if you care about CLS.
Use it safely today
.widget {
width: 100%;
height: 500px; /* fallback everyone gets */
}
@supports (frame-sizing: content-height) {
.widget {
height: auto;
frame-sizing: content-height;
}
}// inside the embedded page
if ('requestResize' in window) window.requestResize();Keep your existing resize script as the fallback, and remove it once support catches up.
TL;DR
| Problem | Fix | Works today? |
|---|---|---|
| Embed is wider than the screen (maps, videos) | width: 100% + aspect-ratio | Yes, everywhere |
| Embed's height doesn't match its content (forms, comments, widgets you control) | frame-sizing: content-height + opt-in meta tag | Chrome 154 behind a flag; use with a fallback |
Go check your contact page on your phone. If it wobbles, you know where to look.
We build hand-coded Astro sites that score 95–100 on PageSpeed, with no sideways scrolling. Let's talk.