我想使用 iFrame 并排显示网页的两个版本,但我在大小和位置属性方面遇到了一些问题。(即使我将其设置为 100,左边的似乎也以很小的高度显示)
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Split</title>
</head>
<body>
<iframe src="link_v1" frameborder="0" scrolling="yes"
style="overflow: hidden; height: 100%;
width: 49%; float: left; " height="100%" width="49%"
align="left">
</iframe>
<iframe src="link_v2" frameborder="0" scrolling="yes"
style="overflow: hidden; height: 100%;
position: absolute;
width: 49%; " height="100%" width="49%"
align="right">
</iframe>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
你的 html 的大小是你的第一个 iframe 的大小
这是因为你position: absolute第二次使用iframe它在 html 和 body 之外,因此它占据了整个高度而不是 html 高度
看看下面的codepen
<iframe src="link_v1" frameborder="0" scrolling="yes"
style="height: 100%;
width: 49%; float: left; " height="100%" width="49%"
align="left">
</iframe>
<iframe src="link_v2" frameborder="0" scrolling="yes"
style="overflow: hidden; height: 100%;
width: 49%; " height="100%" width="49%"
align="right">
</iframe>
Run Code Online (Sandbox Code Playgroud)
这样,他们两人将里面html和body
还设置高度html,并body以100%使这两个I帧占据全高
html,body{
width: 100%;
height: 100%;
}
Run Code Online (Sandbox Code Playgroud)
看看我的 codepen http://codepen.io/war_lock1221/pen/XMzXWb