html - 如何在无滚动 iframe 中重新定位内容?

标签 html css iframe position

我有一个用于 google 图表的 iframe,它周围的间距太大。我想将它嵌入到我的页面中,但要裁剪它以去除周围的空间。

我试图通过将 iframe 设置为较小的 heightwidth 属性来做到这一点,但我不知道如何在 iframe 中重新定位内容以使其居中。

这是图表的 iframe:

<iframe width="550" height="170" seamless frameborder="0" scrolling="no" src="https://docs.google.com/spreadsheets/d/1r56MJc7DVUVSkQ-cYdonqdSGXh5x8nRum4dIGMN89j0/pubchart?oid=1407844401&amp;format=interactive" onload="window.frames['itunes'].scrollTo(250,250)">></iframe>

如何以这种方式重新定位 iframe 的内容,或者有更好的解决方案吗?

谢谢

最佳答案

您应该将 iframe 包裹在 div 或其他东西中并定位 iframe。 这里的代码:

<div class="wrapper">
 <iframe></iframe>
</div>

这是CSS

.wrapper{overflow:hidden;} 
.wrapper iframe{position:relative; left:-40px; top:-30px;}

关于html - 如何在无滚动 iframe 中重新定位内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26175753/

相关文章:

div下的CSS div

javascript - 切换按钮不起作用,菜单无法正常向下滑动

html - 如何将图片和文字并排放置在页面中央?

html - 如何仅删除最后一个 css 规则而不影响除此之外的任何其他和最后一个规则

javascript - magicScroll 仅预制动画第一次向下页面

html - 禁用 <a> 的突出显示

javascript - 在 iframe 中输入字段会导致 iframe 滚动到底部

javascript - iFrame Resizer 将 iFrame 的高度增加到无穷大

javascript - 使用 iFrame 在新窗口中打开 PDF

android - Phonegap HTML5/Android App - Iframe 高度问题