title: How to set iframe size dynamically
body: <p>How should I set the dimensions of an iframe dynamically, so the size is flexible for different viewport sizes?</p>
  
  <p>For example:</p>
  
  <pre><code>&lt;iframe src="html_intro.asp" width="100%" height="300"&gt;
    &lt;p&gt;Hi SOF&lt;/p&gt;
  &lt;/iframe&gt;
  </code></pre>
  
  <p>In this case the height is different depending on the browser's window size. It should be set dynamically depending on the size of the browser window.</p>
  
  <p>At any size, the iframe aspect ratio should be the same. How can this be done?</p>