三星Galaxy S和S II的固定位置

Cod*_*onk 5 html javascript css android-browser

固定定位的div(带有文本'Din Score'的栏和其中的苹果)不会停留在页面底部.这个div类scrollingScoreBoard使用的是javascript,它将保持相对于桌面和笔记本电脑的视图,但会移动到移动视图上的固定位置.

但是,在三星Galaxy S和S II上,它并没有停留在底部.

对于这些特定的手机,我该如何将它固定在底部?

真正的工作地点在这里

HTC One X和三星Galaxy S的比较

在此输入图像描述

所以这就是我所拥有的:

HTML:

<div id="scrollingScoreBoard">
    <div class="currentScoreBox">
        <div class="currentScoreText">
            <p>Din Score</p>
        </div>
        <div class="greenAppleContainer">
            <img class="appleGreenActive" src="eimg/blankApple.png" alt="" >
            <img class="appleGreenDefault" src="eimg/blankApple.png" alt="" >
            <img class="appleGreenDefault" src="eimg/blankApple.png" alt="" >
            <img class="appleGreenDefault" src="eimg/blankApple.png" alt="" >
            <img class="appleGreenDefault" src="eimg/blankApple.png" alt="" >
        </div>
    </div>
</div>
Run Code Online (Sandbox Code Playgroud)

CSS:

#scrollingScoreBoard{
    width: 320px;
    color: white;
    position: relative !important;
    bottom: 0px;
    margin:auto;
    text-align:center;
    left:0;
    right:0;
    background-color:#163c15;
    z-index:1000;
    clear:both;
    }

.currentScoreBox{
    position:relative;
    background:url(../eimg/head_bg.png) 0 0 repeat scroll transparent;
    height:47px;
    width:100%;
    max-width:320px;
    text-align:left !important;
    }

.currentScoreText{
    float:left;
    padding: 2px 0 0 70px;
    }

.currentScoreBox .greenAppleContainer{
    float: left;
    padding: 12px 0 0 12px;
    }

@media screen and (max-width:640px) {

#scrollingScoreBoard{
    width: 320px;
    color: white;
    position: fixed !important;
    bottom: 0px;
    margin:auto;
    text-align:center;
    left:0;
    right:0;
    background-color:#163c15;
    z-index:1000;
    clear:both;
    }
}

@media screen and (max-width:420px) {

    #scrollingScoreBoard{
        width: 100%;
        }
}
Run Code Online (Sandbox Code Playgroud)

JS:

var sticky_offset;
$(document).ready(function() {

    var original_position_offset = $('#scrollingScoreBoard').offset();
    sticky_offset = original_position_offset.top;
    $('#scrollingScoreBoard').css('position', 'relative');


});

$(window).scroll(function () {
    var sticky_height = $('#scrollingScoreBoard').outerHeight();
    var where_scroll = $(window).scrollTop();
    var window_height = $(window).height();


    if((where_scroll + window_height) > sticky_offset) {
        $('#scrollingScoreBoard').css('position', 'relative');
    }

    if((where_scroll + window_height) < (sticky_offset + sticky_height))  {
        $('#scrollingScoreBoard').css('position', 'fixed');
    }

});

$(document).ready(function() {
                window.scrollTo(0,1);
            });
Run Code Online (Sandbox Code Playgroud)

Bor*_*rat -1

我有同样的问题。我可以建议你的是,使用窗口调整大小。我没有尝试那个小提琴,但重点是当你的窗口调整大小时,重新启动粘性栏脚本。

$(window).resize(function(){
    var original_position_offset = $('#scrollingScoreBoard').offset();
    sticky_offset = original_position_offset.top;
    $('#scrollingScoreBoard').css('position', 'relative');
};
Run Code Online (Sandbox Code Playgroud)