custom styling on before and after for hovering and tapping

I want to make a site with before and after pics. I want that you should see the before pic and when mouse hover, you see after. Also, on mobile I want the same effect when someone taps. The pics might not be the same dimensions also. Is there a way to do that? What code would I add to the images/stylesheets or any other file?