我有这个代码:
if(scrollTop < header.orgOffset) {
document.getElementById('log').style.display = 'none';
document.getElementById('lista').style.float = 'none';
document.getElementById('lista').style.marginLeft = 'auto';
header.element.css('background-color', 'transparent').css('width', '100%').css("box-shadow", "none").css('position', orgCSS.position).css('top','').prev().remove();
if(i > 0)
headers[i-1].element.css('z-index', 100);
}
}
//stick headers
for(i in headers) {
var header = headers[i];
//make sure any stuck headers are stuck in the right place(fast scrolling sometimes messes this up)
if(isStuck(header))
header.element.css('top','0')
//skip this header if its bellow the top of the window
if(scrollTop < header.orgOffset - parseInt(orgCSS.height))
break;
//if the header is already stuck then ignore it
if(!isStuck(header)) {
if(scrollTop > header.orgOffset) {
//stick the header
document.getElementById('log').style.display = 'block';
document.getElementById('lista').style.float = 'left';
document.getElementById('lista').style.marginLeft = '20px';
header.element.css("left", "0px").css("box-shadow", "0 0 5px #000").css('background-color', '#FFF').css('width', '100%').css('position', 'fixed').css('z-index','100').css('top','0').before('<div class=menu> </div>');
if(i > 0)
headers[i-1].element.css('z-index', -1);
这适用于我页面中的粘性标题。但是将 float 属性修改为 left 然后再修改为 none 在 Firefox 中不起作用。其他一切都很好,它在铬、rockmelt 和 safari 中都能正常工作。