2011-02-04 105 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'); 

與事件方法懸停或你有什麼想做的事,將其固定..