gpt4 book ai didi

javascript - 在 Samsung Galaxy S 和 S II 上固定位置

转载 作者:太空狗 更新时间:2023-10-29 16:48:23 25 4
gpt4 key购买 nike

固定位置的 div(带有文本“Din Score”和其中的苹果的栏)没有停留在页面底部。此 div 类 scrollingScoreBoard 使用 javascript,它将在桌面和笔记本电脑 View 中保持相对定位,但在移动 View 中将移动到固定位置。

但是,在 Samsung Galaxy S 和 S II 上,它不会停留在底部。

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

真正的工作地点是 here

HTC One X 与三星 Galaxy S 对比

enter image description here

这就是我所拥有的:

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>

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%;
}
}

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);
});

最佳答案

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

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

关于javascript - 在 Samsung Galaxy S 和 S II 上固定位置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21674691/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com