Quantcast
Channel: Active questions tagged html - Stack Overflow
Viewing all articles
Browse latest Browse all 74793

Set iframe height and width to no more than content using CSS

$
0
0

I have an iframe with content which is dynamic in height and width.

<iframe id="myIframe" src="../xxx/xxx" scrolling="no" frameBorder="0"></iframe>

I am able to change the height and width using JavaScript so that my iframe is no bigger than it's content.

var iframe = document.getElementById("myIframe");
iframe.height = iframe.contentWindow.document.body.scrollHeight + 'px';
iframe.width = iframe.contentWindow.document.body.scrollWidth + 'px';

How can I do this using only CSS? Thanks to anyone who can provide guidance.


Viewing all articles
Browse latest Browse all 74793

Latest Images

Trending Articles



Latest Images

<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>