首页 > 解决方案 > 无法在 iOS 中使用HTML

问题描述

我有一个很长的网站,我正在嵌入另一个网站。以下代码适用于桌面浏览器,但不适用于平板电脑或移动设备。

在 iOS 上,当我尝试上下移动页面时,无法滚动。在桌面上,没有问题。

问题:如何更正下面的代码,以便滚动始终在任何浏览器中工作?


代码:

<!DOCTYPE html>
<html lang="en">
   <head>
      <meta name="viewport" content="width=device-width, initial-scale=1.0">
      <style>
         html, body, embed {
         width: 100%;
         height: 100%;
         margin: 0;
         display: block;
         }
      </style>
   </head>
   <body>
      <embed src="http://www.example.com">
   </body>
</html>

标签: htmlioscsswebembed

解决方案


我尝试使用标签在另一个页面中包含一个可滚动的网页。与您的体验相同,嵌入式页面可以在桌面上正常滚动,但在 iOS 上则不行。我切换到一个 iframe,它允许在桌面和 iOS 上滚动 iframe 内容:

<div style="overflow: auto; -webkit-overflow-scrolling: touch;height:450px;" id="my">
    <iframe src="https://www.example.com" style="overflow: auto; -webkit-overflow-scrolling: touch; border: none;" scrolling="yes" width="100%" height="100%"> </iframe>
</div>

推荐阅读