0

Possible Duplicate:
Changing only y pos of background image via Jquery

I want to change only y-position of backournd of .nav-logo while scrolling and keeping x-position consant. I have implemented like this but doesnot get result. Here is my usage code

jQuery(document).ready(function($) {
a=parseFloat(-28);// valor inccial para el background 1
b=parseFloat(1);// valor inccial para el background 1

var scrollTop = $(window).scrollTop();          
var scroll_actually= new Array();// identifica los valoares del background X y  Y

$(window).scroll(function(){//this is not the cleanest way to do this, I'm just keeping it short.
    if(scrollTop>$(this).scrollTop()) // desplazamiento hacia arriba
    {
        if (getScrollTop()<=100 && getScrollTop()>=0)// identyifica cuando la posicion del background_1 esta en scroll
        {
                a=a+1;// posicion del background1 decrementa en 1 pixeles
                b=b+1;// posicion de background1 decrementa en 1 pizeles 
                $('a.qa-logo-link').css('top', +a+'px');
                $('.nav-logo a').css('background-position', -1+'px' , 0+b+'px');    // i think something is wrong here  
        }

    }scrollTop = $(this).scrollTop();});
});
function getScrollTop(){ 



   if(typeof pageYOffset!= 'undefined'){
        //most browsers
        return pageYOffset;
    }
    else{
        var B= document.body; //IE 'quirks'
        var D= document.documentElement; //IE with doctype
        D= (D.clientHeight)? D: B;
        return D.scrollTop;
    }
}

my css file is

.nav-logo a{
background:url("logo1.png") no-repeat scroll  transparent;
background-position:-1px 1px;}
Community
  • 1
  • 1
Rajul
  • 103
  • 3
  • 13

1 Answers1

0

if you want to keep .nav-logo in a static position, use css position:fixed; or position:absolute; and give a left and top values.

UPDATE

updated your sample

http://jsfiddle.net/SbuxT/9/

Chamika Sandamal
  • 23,565
  • 5
  • 63
  • 86