我有一个用于 google 图表的 iframe,它周围的间距太大。我想将它嵌入到我的页面中,但要裁剪它以去除周围的空间。
我试图通过将 iframe 设置为较小的 height
和 width
属性来做到这一点,但我不知道如何在 iframe 中重新定位内容以使其居中。
这是图表的 iframe:
<iframe width="550" height="170" seamless frameborder="0" scrolling="no" src="https://docs.google.com/spreadsheets/d/1r56MJc7DVUVSkQ-cYdonqdSGXh5x8nRum4dIGMN89j0/pubchart?oid=1407844401&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/