safari瀏覽器fixed後,被軟鍵盤遮蓋的問題—【未解決】

safari瀏覽器fixed後,被軟鍵盤遮蓋的問題,已經有好多人問相關的問題,應該是問的角度不同,還的再次提出咯。html

問題描述

測試環境:ios 10.2/10.3html5

簡單來講就是在html5頁面中底部有個fixed的區域,如圖ios

圖片描述

在點擊輸入框的時候,軟鍵盤彈出,遮蓋了fixed區域(這裏頁面總體上移了),如圖web

圖片描述

可是當你點擊「完成」讓軟鍵盤收起,再次點擊輸入框的時候,what?一切正常了~!如圖(就是要這樣子的嘛,以後收起彈出軟鍵盤都正常了,不會遮蓋fixed底部區域了!)segmentfault

圖片描述

可是,可是,還沒完,在輸入框裏隨便輸入點內容,點擊「提交」,關閉軟鍵盤,以後再次點擊輸入框,問題依舊~,軟鍵盤再次遮擋fixed區域。瀏覽器

圖片描述

關閉軟件票,再次點擊輸入框,就不會遮擋fixed區域了。app

如上循環,問題沒法解決。測試

測試代碼以下

代碼很簡單,但仍是貼一下,方便測試,只須要複製粘貼到本機便可測試上述現象ui

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <title>fixed測試頁面</title>
    <meta name="viewport" content="initial-scale=1, maximum-scale=1">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">

    <style>
        .head {
            top: 0;
            height: 50px;
            line-height: 50px;
            text-align: center;
            position: fixed;
            left: 0;
            width: 100%;
            z-index: 10;
            background-color: #99CC00;
        }

        .foot {
            bottom: 0;
            padding: 10px;
            position: fixed;
            left: 0;
            width: 100%;
            background-color: #99CC00;
        }

        .main {
            width: 100%;
            height: 100%;
            overflow-y: scroll;
            -webkit-overflow-scrolling: touch;
        }

        .list {
            padding: 0;
        }

        .list li {
            list-style: none;
            background: #ccc;
            height: 140px;
            margin-bottom: 10px;
            width: 100%;
            padding:10px;
        }
        .list a {
            border:2px solid #999;
            display: block;
            width:88%;
            position: absolute;
            height:140px;
        }
        .input {
            width: 76%;
            line-height: 30px;
            border: none;
            float: left;
            border-radius:5px;
        }
        .btn {
            float:right;
            margin-right:15px;
            border-radius:5px;
            height:34px;
            line-height: 32px;
            padding: 0 10px;
            border: none;
            background: #000;
            color: #fff;
        }
    </style>

</head>

<body>

    <header class="head">頂部固定區域</header>

    <main class="main">
        <div class="content">
            <ul class="list">
                <li><a href="#"></a></li>
                <li><a href="#"></a></li>
                <li><a href="#"></a></li>
                <li><a href="#"></a></li>
                <li><a href="#"></a></li>
                <li><a href="#"></a></li>
                <li><a href="#"></a></li>
                <li><a href="#"></a></li>
                <li><a href="#"></a></li>
                <li><a href="#"></a></li>
            </ul>
        </div>
    </main>

    <footer class="foot" id="footer-fixed">
        <button type="button" id="btn-submit" class="btn" name="button">提交</button>
        <input type="text" id="input-txt" class="input" name="" value="" placeholder="我來講兩句...(200字內)">
    </footer>

</body>

</html>

嘗試過的解決方案

搜索後有不少解決方法,但發現他們都沒解決上述問題,spa

暫時的想法,繞過fixed,用戶點擊輸入框後,隱藏此區域,在頂部出現更大的輸入區域以讓用戶輸入內容。

好,至此,問題描述完畢,期待有牛人更好解決方案

相關文章
相關標籤/搜索