How can I make the video responsive in Webflow when using an embed code div?

Published on
September 22, 2023

To make a video responsive in Webflow when using an embed code div, you can follow these steps:

  1. Insert the embed code div: In Webflow, drag and drop an embed code div into your desired container or section of the page.

  2. Add the video embed code: Double click on the embed code div and paste the video embed code provided by the video hosting service (such as YouTube or Vimeo) into the embed code field.

  3. Set the embed code div's position: With the embed code div selected, go to the styles panel on the right-hand side. Under the position section, choose "Relative" for the position property. This ensures that the div will respond to its surrounding elements.

  4. Adjust the padding: Still in the styles panel, scroll down to the padding section. Add padding to the top and bottom, or left and right, to create spacing around the video.

  5. Enable responsive dimensions: Under the dimensions section in the styles panel, select "Percent" as the unit for width and height. This allows the video to adjust its size proportionally based on the container it is placed in.

  6. Apply max-width property: To avoid the video from scaling beyond its original dimensions, add the CSS property "max-width" to the embed code div. Set the value to 100% to ensure the video never exceeds its original width.

  7. Set aspect ratio: To maintain the correct aspect ratio of the video, add a CSS class to the embed code div. In the styles panel, create a new class and give it a name (e.g., "video-wrapper"). In the class settings, set the padding-bottom property to a percentage that reflects the video's aspect ratio. For example, if the video is in a 16:9 ratio, set the padding-bottom to 56.25% (9/16 * 100).

  8. Apply the aspect ratio class: With the embed code div selected, go to the settings panel on the right-hand side. In the class field, type the name of the class you created in step 7 (e.g., "video-wrapper"). This applies the aspect ratio to the embed code div.

By following these steps, you can make your video responsive in Webflow using an embed code div. This ensures that the video adapts to different screen sizes and maintains its aspect ratio for an optimal viewing experience.

Additional Questions:

  1. How do I add a video to my Webflow website?
  2. How can I optimize videos for SEO in Webflow?
  3. What are the best practices for embedding videos in Webflow?