2011-02-04 109 views
1

我有一个精灵,我想移动使用jQuery另一个div的滚动位置的onClick图像请帮助移动精灵位置与jQuery

.top-background{ 
    background: url("../images/mainall.jpg") no-repeat scroll 0px 0px transparent; 
    height: 888px; 
    width:1024px; 
} 
+0

http://plugins.jquery.com/project/ScrollTo – Rafay 2011-02-04 05:17:57

回答

0
$("#divToClick").click(function(){ 
    $("#yourElementId").scrollTo(//location where to scroll); 

}); 

这里是demo

希望它有助于

1

你可以看到它在早期问题 About sprites

,它是关于重新精灵教程.. CSS sprite

如果妳想要使用jQuery做到这一点:

$('.top-background').css('background-position', 'position_to_show_next_image'); 

与事件方法悬停或你有什么想做的事,将其固定..