开发者

Is sticky footer at bottom possible on iPad website?

开发者 https://www.devze.com 2023-03-07 17:21 出处:网络
Is sticky footer at bottom possible on iPad? I\'m making a website which also need to be compatible on iPad and that site I need to use Sticky footer at Bott开发者_运维百科om.In case it\'s useful for

Is sticky footer at bottom possible on iPad? I'm making a website which also need to be compatible on iPad and that site I need to use Sticky footer at Bott开发者_运维百科om.


In case it's useful for someone else, this code solved it for me for Ipad IOS6 Safari and Chrome:

if (navigator.platform == 'iPad') {
    $("#footer-container").css("position", "static");
    $('#footer-container').css('top', window.innerHeight + window.scrollY - 10 + "px");
}

My situation was that on showing the keyboard my footer div got pushed into the middle of the page.


The problem is that position:fixed is not supported by the iPad, so you need javascript to do the trick, it's not that easy.


As of ios5 position:fixed is supported (partially)


I use this to get it as close as possible. (it does jump, but it's better than nothing.

// IphoneIpad hack, to keep footer on bottom
        $(document).bind('scroll', function() {
            if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i)) || (navigator.userAgent.match(/iPad/i))) {
                $('#footerContainer').css('top', window.innerHeight + window.scrollY - 30 + "px");
            }
        });
0

精彩评论

暂无评论...
验证码 换一张
取 消