如何在iOS6中设置iframe的宽度? [英] How to set the width of an iframe in iOS6?

查看:124
本文介绍了如何在iOS6中设置iframe的宽度?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个必须嵌入某些网站的iframe,而且它在iPhone上没有很好地显示。这是因为移动版Safari会忽略宽度属性(可能还有高度)。

I have an iframe that must be embedded on some websites and it is not well displayed on iPhones. This is because the width attribute (probably height as well) is ignored by mobile Safari.

有解决方法吗?

谢谢!

推荐答案

在移动版Safari中忽略iframe的 width 参数,因此必须使用CSS在px中设置宽度。

The width parameter of the iframe is ignored in mobile Safari so the width must be set in px with CSS.

我通过用JavaScript检查用户代理来解决问题。如果它是iOS设备,我使用CSS将px中的iframe宽度设置为容器的确切大小。

I fixed the problem by checking the user agent with JavaScript. If it's an iOS device, I set the width of the iframe in px with CSS to be the exact size as the container.

这篇关于如何在iOS6中设置iframe的宽度?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆