Hacker News new | ask | show | jobs
by aplummer 3568 days ago
This is a nice use of intrinsic ratio, but it's not a what I would call a "responsive iFrame",you can achieve this by just putting your iFrame in an intrinsic ratio container and laying it out with CSS. The only method I know to make an iframe respond to contain its child element (which might change size, or load slowly) is with a resize listener on the child and postMessage.
2 comments

Technically, the iFrame itself is not responsive but that is what the library does: it wraps it in a container that has more responsive properties than the iFrame.

In addition, I think you may be overloading the word "responsive." This is not a post-message base iFrame resizer, it makes iFrames scale like images. This maintains an aspect ratio which is very desirable in many cases. Think a YouTube embed.

I guess the best way to think about it is that when you omit the height on an image, it will scale when you define its width. iFrames don't do that by default, but this allows them to be scaled.