Note that there are some explanatory texts on larger screens.

plurals
  1. POChange only y-position in background while scrolling
    primarykey
    data
    text
    <blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://stackoverflow.com/questions/4900212/changing-only-y-pos-of-background-image-via-jquery">Changing only y pos of background image via Jquery</a> </p> </blockquote> <p>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</p> <pre><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&gt;$(this).scrollTop()) // desplazamiento hacia arriba { if (getScrollTop()&lt;=100 &amp;&amp; getScrollTop()&gt;=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; } } </code></pre> <p>my css file is </p> <pre><code>.nav-logo a{ background:url("logo1.png") no-repeat scroll transparent; background-position:-1px 1px;} </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload