Display Responsive iframe Maintaining Aspect Ratio
Generally when rendering an iframe, you'll specify the width
and height
properties to give it a fixed display size.
You can make the iframe responsively expand to the full width of its parent while maintaining its aspect ratio using a little CSS.
First, remove the width
and height
properties.
Second, add a wrapping iframe container:
Third, sprinkle on a little CSS to make it responsive:
Ben Marshall has a whole guide to responsive iframes.
Last updated