用jquery修改float不起作用

时间:2012-12-22 07:31:02

标签: jquery html firefox webpage sticky

我有这段代码:

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中不起作用。其他一切都很好,它在铬,岩石和野生动物园中运作良好。

1 个答案:

答案 0 :(得分:0)

对于Firefox,您需要使用cssFloat作为样式属性而不是float。您可以参考thisthis

实施例

document.getElementById('lista').style.cssFloat = 'left';