javascript - iframe 全屏 100% 宽度

标签 javascript html css iframe

我已经成功地使用以下代码制作了一个显示页面特定部分的 Iframe:

<div id="divContainer" style="display: block; margin-left: auto; margin-right: auto;">
     <div id="frameContainer" style="overflow:hidden;">
          <iframe src="http://www.cofm.es/informacion-corporativa/buscador-farmacias" scrolling="no" style="width: 1000px; height: 750px; margin-top: -330px; margin-left: -250px;" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe><br />

</div>

来源:iframe to Only Show a Certain Part of the Page

现在我要做的是让 Iframe 在屏幕上以 100% 的宽度显示。我已经能够使用以下代码对图像执行此操作:

<img style="width: 100%; display: block; margin-left: auto; margin-right: auto; " src="http://i.ytimg.com/vi/ROv863DuJu4/maxresdefault.jpg" />

我试图让 iframe 像图像一样适应屏幕大小。

最佳答案

Iframe 是一个内联元素 - 您需要设置 css“display:block” - 然后您可以将其设置为 100% 并且它会缩放 - 希望这有帮助。 这是一个示例 - 您还必须将包含元素设置为全宽..

<iframe style='display:block;width:100%' src='http://someurl.com'></iframe> 

  https://jsfiddle.net/cqgfqgqk/

关于javascript - iframe 全屏 100% 宽度,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26951248/

相关文章:

javascript - javascript中的逻辑运算符&&和两个字符串

javascript - 如何更改复选框所需的消息

javascript - 如何在 HTML 元素上获得最终的、最终计算出的样式值?

javascript - 为响应式(Reactive)表单控件动态设置值 Angular

javascript - 如何从自定义指令中的 ng-options 获取编译后的数组?

html - 如何让背景图像跨越网格布局

html - 作为横幅的背景图像及其查询的相关文本

css - PrimeNG Accordion 无法正常工作和显示

html - 低效的 CSS 选择器建议

css - 多行垂直居中 <div>