移動端頁面input輸入框被鍵盤遮擋問題

來源:互聯網
上載者:User

標籤:高度   margin   osi   浮動   content   absolute   scrolling   鍵盤   span   

<body class="layout-fixed">    <!-- fixed定位的頭部 -->    <header>            </header>        <!-- 可以滾動的地區 -->    <main>        <!-- 內容在這裡... -->    </main>        <!-- fixed定位的底部 -->    <footer>        <input type="text" placeholder="Footer..."/>        <button class="submit">提交</button>    </footer></body>v
header, footer, main {    display: block;}header {    position: fixed;    height: 50px;    left: 0;    right: 0;    top: 0;}footer {    position: fixed;    height: 34px;    left: 0;    right: 0;    bottom: 0;}main {    margin-top: 50px;    margin-bottom: 34px;    height: 2000px}

下面這個樣子。

鍵盤喚起下面這樣

是為什麼呢?:  軟鍵盤喚起後,頁面的 fixed 元素將失效(即無法浮動,也可理解為成了 absolute 定位)

解決方案: 將原 body 滾動的地區域移到 main 內部

header, footer, main {    display: block;}header {    position: fixed;    height: 50px;    left: 0;    right: 0;    top: 0;}footer {    position: fixed;    height: 34px;    left: 0;    right: 0;    bottom: 0;}main {    /* main絕對位置,進行內部滾動 */    position: absolute;    top: 50px;    bottom: 34px;    /* 使之可以滾動 */    overflow-y: scroll;
  /* 增加該屬性,可以增加彈性 */
  -webkit-overflow-scrolling: touch;}main .content { height: 2000px;
}
 

 

h5底部輸入框被鍵盤遮擋問題
var oHeight = $(document).height(); //瀏覽器當前的高度      $(window).resize(function(){         if($(document).height() < oHeight){                 $("#footer").css("position","static");    }else{                 $("#footer").css("position","absolute");    }           });

 

js解決軟鍵盤遮擋輸入框問題

連結 http://blog.csdn.net/u011500781/article/details/53926425

移動端頁面input輸入框被鍵盤遮擋問題

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.