固定定位的div(带有文本'Din Score'和苹果的栏)不会停留在页面底部。这个div类scrollingScoreBoard
正在使用javascript,它将保持相对于桌面和笔记本电脑视图的位置,但会移动到移动视图上的固定位置。
但是,在三星Galaxy S和S II上,它并没有停留在最底层。
我应该如何将它固定在这些特定手机的底部?
真正的工作网站是 here
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>
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);
});
答案 0 :(得分:-1)
我遇到了同样的问题。我建议你的是,使用窗口调整大小。 我没有尝试那个小提琴,但重点是当你的窗口调整大小时,重新启动粘性条形码。
$(window).resize(function(){
var original_position_offset = $('#scrollingScoreBoard').offset();
sticky_offset = original_position_offset.top;
$('#scrollingScoreBoard').css('position', 'relative');
};