Sliding divs horizontally with JQuery

Unfortunately there is no ready made ‘horizontal’ slide animation with jQuery. Unless you go with bigger packages like jQuery UI. But I don’t think that is needed.

The only thing you want is some creative use of the animate() function in jQuery to achieve an effect.

I didn’t know which one you’d want to go with since the description was vague so I made 2 examples for minor effects in panel switching:

http://jsfiddle.net/sg3s/rs2QK/ – This one slides panel open from the left and to close to the right

http://jsfiddle.net/sg3s/RZpbK/ – Panels slide open from left to right and close to the left befor opening the new one.

Resources:

You can’t do this with pure CSS, not yet anyways. The support for transitions is basic and limited to pretty much only webkit based browsers. So since you’re going to need jQuery make smart use of it, but you still need to make sure you style as much as possible with css before you use the JS. Note that I don’t use any visual styling / manipulations in my JS.

Leave a Comment