Webflow sync, pageviews & more.
NEW

How can I make my iframe embed responsive in Webflow?

TL;DR
  • Wrap the iframe in a Div with class (e.g., iframe-wrapper) and set its position to relative, height to 0, width to 100%, and padding-top (e.g. 56.25%) to maintain aspect ratio.
  • Inside the wrapper, set the iframe to position absolute with top/left 0 and width/height 100% to ensure full scaling.

To make your iframe embed responsive in Webflow, you need to control its aspect ratio inside a container that scales with the page.

1. Wrap the Iframe in a Div Block

  • Drag a Div Block onto your canvas to serve as a wrapper for the iframe.
  • Give the Div a class name like iframe-wrapper.
  • Inside the Div, add your Embed element or paste your iframe code directly if you're using the Embed component.

2. Set the Wrapper to Maintain Aspect Ratio

  • Select the iframe-wrapper Div and set its position to relative.
  • Give it a padding-top value to simulate aspect ratio. For 16:9 ratio (standard for videos), set padding-top: 56.25%.
  • Set height to 0px.
  • Set width to 100% so it adjusts with the parent container.

3. Style the iFrame for Full Coverage

  • In the iframe's Embed block, after pasting the iframe code, apply inline styles to the iframe tag:
  • Add width="100%", height="100%".
  • Add style="position:absolute; top:0; left:0; width:100%; height:100%;" directly in the iframe element.

Example iframe tag (within the Embed element):
<iframe src="your-video-url" frameborder="0" allowfullscreen style="position:absolute; top:0; left:0; width:100%; height:100%;"></iframe>

4. Check Display Settings

  • Ensure the Embed element itself is not adding extra padding or margins.
  • Make sure the containing sections or grids are mobile-responsive.

Summary

Wrap your iframe in a Div that uses padding-top for aspect ratio, position the iframe absolutely inside that wrapper, and set its width and height to 100%. This will make your iframe scale fluidly across all screen sizes.

Rate this answer

Other Webflow Questions