There is an iframe in a div, and the div is required to display part of the content of the iframe, and the div is required to change proportionally as the browser becomes larger or smaller. How to achieve this? _html/css_WEB-ITnose

WBOY
Release: 2016-06-24 11:52:58
Original
1746 people have browsed it

There is an iframe in a div. The div is required to display part of the content of the iframe, and the div is required to change proportionally as the browser becomes larger or smaller. How to achieve this?

You can also use javascript to do it, as long as it can be implemented.

Ask the experts to give it a try. If you don’t score enough, you can get extra points!



Reply to discussion (solution)

Is that so?

  <style>html,body{height:100%;}</style><div style="width:50%;height:50%;position:relative;"><iframe src="http://www.baidu.com" style="width:100%;height:100%;position:absolute;top:0px;left:0px;"></iframe></div>
Copy after login

The content displayed by the iframe is controlled by the width, and the div is used as a percentage as the browser becomes larger or smaller,


frameborder="0" scrolling="no" width="100%" height="100%" src="http://www.baidu.com">


<script> <br> window.setInterval(function(){ <br> iFrameHeight() <br> }, 100); <br> function iFrameHeight() { <br> <br> var ifm= document.getElementById("iframeH"); <br> var subWeb = document.frames ? document.frames["iframeH"].document : ifm.contentDocument; <br> ifm.height = subWeb.body.scrollHeight; <br> <br> <br> } <br> </script>

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template