• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

html - 我怎样才能使位置:fixed work on iOS 7?

[复制链接]
菜鸟教程小白 发表于 2022-12-12 15:17:54 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题

我创建了一个测试网页,演示 UIWebView 和 Mobile Safari 上的 position:fixed 问题:

<!DOCTYPE html>
<html style="overflow: hidden; ">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.2, user-scalable=no">
  <title>Test</title>

  <style type="text/css">
    * {
      -webkit-tap-highlight-color: rgba(0,0,0,0);
    }
    body {
      margin: 0px;
      padding: 0px;
    } 
    .fullscreen {
      background: transparent;
      display: block;
      position: absolute;
      top: 0; left: 0;
      width: 100%;
      height: 100%;
    }
    .screen {
      position: fixed;
      left: 0px;
      top: 0px;
      width: 100%;
      height: 100%;
      /*-webkit-box-shadow: inset 0 0 10px #0d1f2b;
      -moz-box-shadow: inset 0 0 10px #0d1f2b;
      -o-box-shadow: inset 0 0 10px #0d1f2b;*/
      box-shadow: inset 0 0 10px #0d1f2b;
    }
  </style>
</head>
<body>
  <div class="screen" id="screen"></div>
  <form><textarea id="code" name="code" class="fullscreen" rows="1">
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
1
2
3
4
5
6
7
8
9
0
  </textarea></form>
</body>
</html>

重现步骤:

  1. 在 iPad 或 iPhone 上的 Mobile Safari 上打开演示网页。
  2. 点击文本区域以显示键盘。
  3. 向上或向下滚动以查看问题。

嵌入的阴影应该沿着浏览器窗口的边缘,但它不正确地位于页面下方。

enter image description here

如何使 position:fixed 正常工作?



Best Answer-推荐答案


原始问题没有答案,但它是具有相同结果的解决方案。将 body 的样式更改为以下内容:

.body {
  margin: 0px;
  padding: 0px;

  /*-webkit-box-shadow: inset 0 0 10px #0d1f2b;
  -moz-box-shadow: inset 0 0 10px #0d1f2b;
  -o-box-shadow: inset 0 0 10px #0d1f2b;*/
  box-shadow: inset 0 0 10px #0d1f2b;

  min-height: 100%;
}

screen 元素可以被移除。

关于html - 我怎样才能使位置:fixed work on iOS 7?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19179792/

回复

使用道具 举报

懒得打字嘛,点击右侧快捷回复 【右侧内容,后台自定义】
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

关注0

粉丝2

帖子830918

发布主题
阅读排行 更多
广告位

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap