iOS iPad Fixed position breaks when keyboard is opened

前端 未结 7 1885
春和景丽
春和景丽 2020-12-07 11:21

Fixed position breaks on header when I click on the \"Search Form\" text box field. It simply detaches from the top of the page (as it\'s fixed up there) and starts floating

7条回答
  •  伪装坚强ぢ
    2020-12-07 11:48

    Here's a hacky solution using jQuery:

    HTML:

     
    
    
    
    
    my fixed position container

    CSS:

    .ad_wrapper {
        position: fixed;
        bottom: 0;
        left: 0;
        width: 100%;
        height: 40px;
        background-color: rgba(0,0,0,0.75);
        color: white;
        text-align: center;
    }
    .unfixed {
        position: relative;
        left: auto;
        bottom: auto;
    }
    

    JS:

    $(function () {
        adWrapper = $('.ad_wrapper');
    
        $(document).on('focusin', 'input, textarea', function() {
            adWrapper.addClass('unfixed');
        })
        .on('focusout', 'input, textarea', function () {
            adWrapper.removeClass('unfixed');
        });
    });
    

提交回复
热议问题