Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
461 views
in Technique[技术] by (71.8m points)

javascript - Dynamic iframe corresponding to 100vh in HTML embedded link?

I am embedding a link to a web page using an iframe with no height or width settings. What would the iframe embed code be if I wanted to embed the iframe where the size of the iframe will also be the size of the vh. As an example I am hosting the html code for the link I am embedding and I need the height of the iframe to correspond to the 100vh that is referenced in the HTML code.

<iframe src='https://www.google.com' ></iframe>

vs.

<iframe src='https://www.google.com' width=?  height=? ></iframe>
question from:https://stackoverflow.com/questions/65829178/dynamic-iframe-corresponding-to-100vh-in-html-embedded-link

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

You can set style for iframe

<!DOCTYPE html>
<html>
  <style>
    iframe {
      height: 50vh;
      width: 100%;
    }
  </style>
<body>
  <iframe src="iframe.html"/>
</body>
</html>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...