【发布时间】:2017-06-29 07:37:30
【问题描述】:
我正在创建一个网页,该网页使用来自 python 库 Bokeh 的自动生成的 html 文件。我使用库导出 html 文件,然后使用 iframe 显示信息。
我想不出任何方法来使这个 iframe 的内容居中。
我尝试的 CSS 代码如下所示:
div.box {
display: block;
margin:auto;
}
iframe.d {
border: none;
width: 100%;
display:block;
}
身体看起来像:
<div class = 'box'>
<iframe class = 'd' src='graphs.html' id = 'beautifulgraphs' onload='autoResize("beautifulgraphs")'></iframe>
</div>
但我希望您可以查看下面的 plunker 以了解实际问题。
这是指向我的 HTML 的 plunker 链接:Plunker HTML
我在 plunker 自述文件中附上了如何查看问题的说明,但请预览代码,然后使用蓝色小按钮将预览弹出到全屏模式。然后很明显,居中不起作用。
我已经尝试了this link 上的建议,但没有成功。
【问题讨论】:
-
如何将 iframe 宽度设为 100%,然后期望它居中?在 plunker 中,iframe 上方的表格宽度为 70%,在 iFrame 上设置相同就可以了。否则,您会将 iframe 的内容更改为 iframe 的中心。
标签: javascript html css iframe bokeh