Safari在ios8是固定的元素获得焦点时滚动屏幕 [英] Safari in ios8 is scrolling screen when fixed elements get focus

查看:253
本文介绍了Safari在ios8是固定的元素获得焦点时滚动屏幕的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在IOS8 Safari中有一个新的位置固定的错误。

In IOS8 Safari there is a new bug with position fixed.

如果您将textarea集中在一个固定的面板,safari会滚动到底部这一页。

If you focus a textarea that is in a fixed panel, safari will scroll you to the bottom of the page.

这使得各种UI不可能使用,因为你没有办法输入文本到textareas没有滚动你的页面一直向下,失去你的地方。

This makes all sorts of UIs impossible to work with, since you have no way of entering text into textareas without scrolling your page all the way down and losing your place.

有没有办法解决这个bug干净?

Is there any way to workaround this bug cleanly?

#a {
  height: 10000px;
  background: linear-gradient(red, blue);
}
#b {
  position: fixed;
  bottom: 20px;
  left: 10%;
  width: 100%;
  height: 300px;
}

textarea {
   width: 80%;
   height: 300px;
}



<html>
   <body>
   <div id="a"></div>
   <div id="b"><textarea></textarea></div>
   </body>
</html>


推荐答案

基于好的分析这个问题,我在 html body 元素在css中:

Based on this good analysis of this issue, I've used this in html and body elements in css:

html,body{
    -webkit-overflow-scrolling : touch !important;
    overflow: auto !important;
    height: 100% !important;
}

我认为它对我很有用。

这篇关于Safari在ios8是固定的元素获得焦点时滚动屏幕的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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