Move the background image on mouse over (Single Parallax)

前端 未结 3 542
囚心锁ツ
囚心锁ツ 2020-12-14 11:37

I would like to make the background image move slightly on the X and Y axis when the mouse is in the \"landing-content\" DIV, it should move with the movement of the mouse.

3条回答
  •  误落风尘
    2020-12-14 12:34

    Check this fiddle. I think you will find what you want. http://jsfiddle.net/Aveendra/uXPkE/

    $('#landing-content').mousemove(function(e){
        $(this).css('background-position',''+e.pageX/10+'px '+e.pageY/10+'px');
    });
    

提交回复
热议问题