Javascript 三星Galaxy S和S II上的固定位置
固定位置的div(带有文本“Din Score”和苹果的条)没有停留在页面底部。这个div类scrollingScoreBoard使用了一个javascript,它在桌面和笔记本电脑视图中保持相对位置,但在移动视图中移动到固定位置 但是,在三星Galaxy S和S II上,它并没有停留在底部 对于这些特定的手机,我应该如何将其固定在底部 真正的工作地点是 HTC One X与三星Galaxy S的比较 这就是我所拥有的: HTML: JS:Javascript 三星Galaxy S和S II上的固定位置,javascript,html,css,android-browser,Javascript,Html,Css,Android Browser,固定位置的div(带有文本“Din Score”和苹果的条)没有停留在页面底部。这个div类scrollingScoreBoard使用了一个javascript,它在桌面和笔记本电脑视图中保持相对位置,但在移动视图中移动到固定位置 但是,在三星Galaxy S和S II上,它并没有停留在底部 对于这些特定的手机,我应该如何将其固定在底部 真正的工作地点是 HTC One X与三星Galaxy S的比较 这就是我所拥有的: HTML: JS: var\u偏移量; $(文档).ready(函数()
var\u偏移量;
$(文档).ready(函数(){
var original_position_offset=$(“#ScrollingCoreboard”).offset();
粘滞偏移=原始位置偏移.top;
$('#scrollingScoreBoard').css('position','relative');
});
$(窗口)。滚动(函数(){
var sticky_height=$(“#ScrollingCoreboard”).outerHeight();
var,其中_scroll=$(window.scrollTop();
var window_height=$(window.height();
如果((其中滚动+窗口高度)>粘滞偏移){
$('#scrollingScoreBoard').css('position','relative');
}
如果((其中滚动+窗口高度)<(粘滞偏移+粘滞高度)){
$('#scrollingScoreBoard').css('position','fixed');
}
});
$(文档).ready(函数(){
窗口。滚动到(0,1);
});
我也有同样的问题。我建议您使用窗口大小调整。
我没有试过小提琴,但关键是当你调整窗口大小时,重新启动粘滞条脚本
$(window).resize(function(){
var original_position_offset = $('#scrollingScoreBoard').offset();
sticky_offset = original_position_offset.top;
$('#scrollingScoreBoard').css('position', 'relative');
};
你有矛盾的
立场:!重要的此div的代码中的code>。这是脏的,可能会混淆浏览器。顺便说一句,这里没有显示所有相关的CSS。现在我有了所有相关的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%;
}
}
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);
});
$(window).resize(function(){
var original_position_offset = $('#scrollingScoreBoard').offset();
sticky_offset = original_position_offset.top;
$('#scrollingScoreBoard').css('position', 'relative');
};