<iframe>
"is not being responsive":
I have what seems to be responsive <iframe>
code. See this Pen on Codepen. (Note: the embedded site used in the Pen is a parallax site. Although the <iframe>
is responsive, the parallax functionality is lost at mobile sizes. Non-parallax sites seem to function correctly. Try href="http://www.popularmechanics.com/space/a11137/secrets-of-the-water-bear-the-only-animal-that-can-survive-in-space-17069978/" as an example.)
The markup and CSS were developed from three sources:
- The Stack Overflow Thread Scaling iframes for responsive design CSS-only,
- The Ben Marshall article How to Make Responsive Iframes — it’s easy!, and
- The Rachel McCollin article Making Embedded Content Work In Responsive Design.
Three salient points are:
- Specify no attributes in the opening
<iframe>
tag other than src, specifically not height and width.
- Wrap the
<iframe>
in both an inner <div>
and an outer <div>
.
- Style the inner
<div>
inline with style="-webkit-overflow-scrolling: touch; overflow: auto" which are necessary for proper scrolling and overflow handling on mobile devices but which are unstable in CSS. (I found this in a fourth article; I did not save the reference and cannot find it again.)
The rationale behind the markup structure and CSS can be found in the cited sources.
I hope this helps.