Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to split the image using Javascript + CSS?

I have the image like this:

alt text

I want to split it into six squares, and I can keep looping to display the animation. Do you have any ideas to split the image by JS + CSS instead of using 6 separate image files.

like image 809
DNB5brims Avatar asked Dec 05 '25 17:12

DNB5brims


2 Answers

Set it as a background image and manipule the background position.

Update: As seth mentioned, the technique is called CSS Sprites. Searching google for animation with css sprites turns up some good results.

like image 129
Chris Van Opstal Avatar answered Dec 08 '25 07:12

Chris Van Opstal


Here's an article from SitePoint on sprite animation using jQuery.

like image 33
wongo888 Avatar answered Dec 08 '25 07:12

wongo888



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!