Making a toggle with sprite

Hello, I’m trying to make a toggle with a sprite that shows an ON image and an OFF image - like what you see in a native mobile app. I can easily create a show/hide toggle but what about one that swaps between bg image position or 2 images?

Maybe try to put your image in a div the size of the switch, set to Overflow:hidden and Position:relative, and change the image absolute position.