css - 我需要在一页上有 2 个 iframe,一个在另一个顶部

标签 css html iframe frame

所以我需要在一页上创建一个带有 2 个 iframe 的 html 页面,一个在另一个顶部...顶部的将占据大部分页面,底部的将大约 80px 高...查看 JSFiddle下面。

我的代码似乎可以工作,但我注意到每当我滚动某些页面时,滚动会跳来跳去……它并不总是流畅的滚动体验……所以我的问题是……

是否有更好的方法来实现我想要做的事情?还是这是最好的方法?

html

<div id="frame2">
   <iframe name="frame2" src="" style="height: 80px; width: 100%; border: none;"></iframe>
</div><!-- close div#frame2 -->

<div id="frame1">
   <iframe name="frame1" src="http://www.apple.com/" style="height: 100%; width: 100%; border: none;"></iframe>
</div><!-- close div#frame1 -->

CSS

#frame1 {
   background-color: #0099ff;
   position: absolute;
   top: 0px;
   left: 0px;
   bottom: 80px;
   right: 0px;
}

#frame2 {
   background-color: #000000;
   position: absolute;
   top: 0px;
   left: 0px;
   bottom: 0px;
   right: 0px;
}

这里还有代码的 jsfiddle ( http://jsfiddle.net/jstormthakid/TMSwq)。

如有任何帮助,我们将不胜感激...

最佳答案

DEMO HERE

html,body {
    height:100%;
}
.h_iframe1 iframe {
    position:absolute;
    top:0;
    left:0;
    width:100%; 
    height:calc(100% - 120px);
}
.h_iframe2 iframe {
    position:absolute;
    bottom:0;
    right:0;
    width:100%; 
    height:120px;
}

我不想在第一个 iframe 中显示滚动条 demo here

.h_iframe1 iframe {
    position:absolute;
    top:0;
    width:100%; 
    height:calc(100% - 120px);
    right: -30px;   
    padding-right: 15px;
    overflow-y: scroll;
}

关于css - 我需要在一页上有 2 个 iframe,一个在另一个顶部,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23165243/

相关文章:

html - 使侧边栏导航选项卡处于事件状态?

java - 如何使用 Struts2 中 Action 类的数组填充 SelectBox?

javascript - 你能用 jquery 获取继承的元素类吗?

ionic-framework - 如果在 Ionic 3 中聚焦,iframe 会再次重新加载

jquery - 使用 jQuery 更改某些 iframe src 属性时浏览器崩溃

html - visibility :hidden freezes animation inside iframe in Chrome and Opera (WebKit likely)

javascript - 页面中心的水平滚动部分

javascript - 如果所有子div都隐藏了,如何隐藏父div?

html - CSS3 - 如何将 "restore"::-webkit-scrollbar 属性设置为默认滚动条

HTML/CSS Plotly 绘图大小