To make an iframe embed responsive in Webflow, you need to wrap the iframe in a div with a fixed aspect ratio and apply CSS settings to scale the iframe properly within that container. Webflow doesn't automatically make iframes responsive.
1. Wrap the Embed in a Div Block
- Drag a Div Block onto your page where you want the iframe.
- Give it a class name, such as
responsive-embed. - Set the position to Relative in the Style panel.
2. Create Responsive Aspect Ratio
- In the Style panel for the
responsive-embed div: - Set Padding-Top to define the aspect ratio (e.g., use 56.25% for 16:9).
- Set Width to 100%.
- Set Height to 0px.
- This uses the padding-top % trick, where padding is based on width—thus keeping the aspect ratio.
3. Embed the Iframe Absolutely
- Drag an Embed element into the
responsive-embed div. - Paste your iframe code inside—but remove width and height attributes if they exist.
- Click out of the embed and select it.
- In the Style panel for the embed:
- Set Position to Absolute.
- Set Top, Bottom, Left, and Right to 0.
- Set Width and Height to 100%.
4. Optional: Optimize for Loading
- You can add attributes directly inside your iframe tag for better performance:
- Use loading="lazy" to defer loading until it's in view.
- Add title for accessibility best practices.
Summary
To make iframes responsive in Webflow, wrap the iframe in a relatively positioned div with a fixed aspect ratio using padding-top, then set the iframe to be absolutely positioned and scaled to 100% of its parent container. This ensures it scales fluidly on different screen sizes.