如何调整 iframe 的大小? (CSS 媒体查询?)
大家好,我想根据浏览器窗口的大小调整 iframe 的大小,但我也改变了高度和宽度。非常感谢对我感到困惑的地方进行一些解释。
我了解如何使用 css 媒体查询根据屏幕尺寸使用 diff 样式表,但是当我必须预定义 iframe 内的高度和宽度时,这如何应用于位于另一个网站上的 iframe?
您是否需要在 iframe 内定义高度和宽度?或者您可以使用媒体查询来检测包含 iframe 的浏览窗口的大小,然后根据该大小设置高度和宽度值。
例如,通常是 iframe 中的内容,但是如果另一个网站在 iPhone 上启动,我如何才能使 iframe 看起来像这样呢?
或者我错过了什么?
Hi guys I'm looking to resize an iframe depending on size of the browser window, but I'm all turned around as too the height and width. Would REALLY appreciate some explanation on where I'm confused.
I understand how to use css media queries use diff stylesheets according to screen size, but how does this apply to an iframe that's located on another website when I have to predefine the height and the width inside the iframe?
Do you even need the height and width to be defined inside the iframe? Or can you use media queries to detect the size of the browsing windows containing the iframe and then set the height and width values depending on that.
For instance is what's normally in the iframe, but how would I get the iframe to be something like if the other website is brought up on an iphone?
Or am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
尝试将 iframe 高度/宽度设置为百分比。就像:
这将导致 iframe 扩展到其最大可能大小,具体取决于其父容器。
Try setting your iframe height/width to a percentage. Like:
That will cause the iframe to expand to it's maximum possible size depending on its parent container.