固定标题与移动safari网站上的文本字段 [英] Fixed headers with text fields on mobile safari websites

查看:120
本文介绍了固定标题与移动safari网站上的文本字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在寻找一段时间,我似乎找不到任何修复这个问题。当输入字段在移动safari中获得焦点(尚未检查其他浏览器)时,由于safari将该元素置于视图中(更靠近中心),固定元素将跳跃。错误只发生在用户滚动时,如果用户仍在页面顶部,则不会发生任何操作。

I've been looking around for awhile, and I can't seem to find any fix for this issue. When an input field gains focus in mobile safari (haven't checked other browsers) a fixed element will jump due to safari putting that element in view (closer to the center). The error only occurs when a user has scrolled, if the user is still at the top of the page nothing occurs.

之前&截图后

有没有人有一个线索如何解决这个问题?我遇到的唯一的解决方案是回到顶部,当焦点,然后在模糊滚动回到位置...这看起来像一个非常马虎的解决方案。

Does anyone have a clue how to fix this? The only solution I have come across is to scroll back to the top when focused, then on blur scroll back into position... this seems like a very sloppy solution.

下面是屏幕截图中的示例网站,非常基本,没有任何规范。

Here's the example site in the screenshots, very basic, nothing out of the norm.

    <!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8" />
        <meta name="viewport" content="width=device-width, scale=1"/> 
    <title>MySite</title>
    <style>
    body{
        height:100%;
        width:100%;
        padding:0;
        margin:0;
        font-size:16px;
        font-family: "HelveticaNeue-Light", "Helvetica Neue Light", "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif;
    }
    header, footer {
        background-color:#333;
        padding:10px;
        color:#FFF;
        width:100%;
    }
    header {
        position:fixed;
        top:0;
        left:0;

    }
    input[type=search] {
        position:relative;
        margin-left:20px;
        width:160px;
        font-size:16px;
        height:26px;
    }
    section{
        padding:10px;
    }
    </style>
</head>
<body>
<header>
<b>MySite</b>
<input type='search' placeholder='Search'>
</header>
<section>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
</sction>
<footer>
&copy; MySite <?php echo date('Y') ?>
</footer>
</body>
</html>


推荐答案

但我意识到,固定的位置只是延迟,不破(至少对我来说)。滚动并等待5-10秒,看看搜索栏是否调整回到屏幕顶部。我相信这不是一个错误,但键盘打开时响应延迟。

I have the same issue. But I realized that the fixed position is just delayed and not broken (at least for me). Scroll and wait 5-10 seconds and see if the search bar adjusts back to the top of the screen. I believe it's not an error but a delayed response when the keyboard is open.

这篇关于固定标题与移动safari网站上的文本字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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