我为
我使用了固定的思想,但试图将其限制在管线上。 它不是完美的,而是得到页数短的帮助。 Also, when I scroll with my iPhone, it works but only after I finish scrolling and not as I m scrolling. Is this just a limitation of the iPhone s scrolling mechanism or is there a way around that? 精神水平采用固定定位,内部的一切都绝对定位(与精神水平相对)。 www.un.org/Depts/DGACM/index_french.htm Wow,我刚刚与三星银河S1(标准网络浏览器)进行核对。 测量磁带的z积和绝对定位是灾难性的失败。 为什么如此?How could I make it smoother (particularly when scrolling slowly)?
The HTML:
<div id="spirit_level">
<div id="shimmery"></div> <!-- just for y gradient -->
<div id="shimmerx"></div> <!-- just for x gradient -->
<div id="bumps"></div> <!-- just for another overlay -->
<div id="tube">
<div id="bubble"></div>
<div id="overside"></div> <!-- glass + line markings -->
</div>
</div>
<div id="spirit_shadow"></div>
The CSS:
The Javascript:
/* START: init spirit_level/bubble */
var bubble_h = 53, tube_h = 242,
doc_h = parseInt($(document).height()),
viewport_h = parseInt($(window).height()),
scrollDepth = $(document).scrollTop(),
orig_scrollDepth = scrollDepth,
tube_top = viewport_h/2 - tube_h/2,
center = 0;
/*center the tube and bubble:
$( #tube ).css( top , tube_top+ px )
.addClass( bubble_prep );
placeBubble(1);
/* END: init spirit_level/bubble */
$(window).unbind("scroll").scroll(function () {
placeBubble(0);
})
function placeBubble(first_time)
{
scrollDepth = $(document).scrollTop();
if(first_time)
{
$( #bubble ).css( top , center + px );
}
temp = ((center - (scrollDepth - orig_scrollDepth))/viewport_h)*100;
$( #bubble ).css( top , (temp<-50?-50:(temp>50?50:temp)) + % )
.animate(
{top: (center/viewport_h)*100+ % },
{duration:800,queue:false},
{
step: function(now, fx) {
//this is never called, don t know why
alert(now);
}
}, function(){
/*
Should I do the following?
orig_scrollDepth = $(document).scrollTop();*/
});
/*Without the next line, the bubble slides down from the top of the
tube on any length scroll in any direction*/
orig_scrollDepth = $(document).scrollTop();
}
}
Edit:
I am trying to create a search text-field like on the Apple website. The HTML looks like this: <div class="frm-search"> <div> <input class="btn" type="image" src="http://www....