How can I make the iFrame on my Webflow site auto size the height to fit the content without needing to scroll on mobile devices?

Published on
September 22, 2023

To make the iFrame on your Webflow site auto-size the height to fit the content without needing to scroll on mobile devices, you can follow these steps:

  1. Add the iFrame embed code to your Webflow site. You can do this by dragging an Embed element onto your page and pasting the iFrame code into the HTML embed field.

  2. Give the iFrame element a class name. This will allow you to style and target the iFrame specifically.

  3. Go to the Custom Code section of your Webflow project settings. You can access this by clicking on the project settings icon in the left sidebar and selecting the Custom Code tab.

  4. In the Head Code section, add the following CSS snippet:

<style>  .your-iFrame-class-name {    height: 100vh;    width: 100%;    overflow: hidden;  }</style>

Make sure to replace your-iFrame-class-name with the actual class name you gave to your iFrame in Webflow.

  1. Publish your Webflow site to see the changes reflected on the live site.

This CSS snippet will set the height of the iFrame to 100vh, which means it will take up 100% of the viewport height. The width: 100% ensures that the iFrame spans the entire width of the screen. The overflow: hidden property hides any content that exceeds the specified height and removes the need for scrolling on mobile devices.

By following these steps, the iFrame on your Webflow site will automatically adjust its height to fit the content without the need for manual scrolling on mobile devices.

Additional Questions:

  1. How do I embed an iFrame in Webflow?
  2. How do I style an iFrame in Webflow?
  3. Can I make the iFrame responsive in Webflow?