From our sponsor: Ready to show your plugin skills? Enter the Penpot Plugins Contest (Nov 15-Dec 15) to win cash prizes!
Today we want to share a slick and flexible vertical jQuery accordion with you. The main idea is to expand the accordion slices on click and show some more information. The other slices will become less opaque and squeezed. When navigating to the next slice using one navigation arrows, a new slice will slide in from the top or the bottom. Once a slice is open and we navigate, the subsequent slice will open on slide.
The beautiful portrait photography is by Images by Alan Turkus. Check out his Flickr Photostream. The images are licensed under the Creative Commons Attribution 2.0 Generic (CC BY 2.0) License.
We also use the jQuery Mousewheel Plugin by Brandon Aaron which allows us to navigate through the accordion using the mouse wheel.
The options for this plugin allow to customize the height and width, the number of slices visible, the height of an expanded slice and others. Let’s first see some examples before we explain each option.
Tiny break: 📬 Want to stay up to date with frontend and trends in web design? Subscribe and get our Collective newsletter twice a tweek.
Examples
Take a look at all the examples (you can also navigate from them to all the other demos):
- 3 visible slices / Default
- With easing
- 5 visible Slices and higher transparency
- 2 visible slices and slower animation
- Fullscreen example
For the HTML structure we have the accordion container, the navigation spans and the wrapper with the slices:
<div id="va-accordion" class="va-container"> <div class="va-nav"> <span class="va-nav-prev">Previous</span> <span class="va-nav-next">Next</span> </div> <div class="va-wrapper"> <div class="va-slice va-slice-1"> <h3 class="va-title">Marketing</h3> <div class="va-content"> <p>Henry Watson</p> <ul> <li><a href="#">About</a></li> <li><a href="#">Portfolio</a></li> <li><a href="#">Contact</a></li> </ul> </div> </div> <div class="va-slice va-slice-2"> ... </div> </div> </div>
We give each slice a different class to define a background image for them. In the last fullscreen example we have color classes to assign a different background color to each slice.
Let’s take a look at the example with just 2 slices and a slower animation speed:
$('#va-accordion').vaccordion({ expandedHeight : 350, animSpeed : 400, animOpacity : 0.7, visibleSlices : 2 });
The following options are available:
// the accordion's width accordionW : 1000, // the accordion's height accordionH : 450, // number of visible slices visibleSlices : 3, // the height of a opened slice // should not be more than accordionH expandedHeight : 350, // speed when opening / closing a slice animSpeed : 250, // easing when opening / closing a slice animEasing : 'jswing', // opacity value for the collapsed slices animOpacity : 0.2, // time to fade in the slice's content contentAnimSpeed: 900, // if this is set to false, // we collapse any opened slice // before sliding savePositions : true
If you, for example, would like to show a slice fully on expansion, using the whole height of the accordion container, then you set the expandedHeight to the same value like the accordionH (the height of the accordion). In our last example we used the full window width and height and also adjusted some style (see inline style in the example) in order to remove any margins:
$('#va-accordion').vaccordion({ accordionW : $(window).width(), accordionH : $(window).height(), visibleSlices : 5, expandedHeight : 450, animOpacity : 0.1, contentAnimSpeed: 100 });
We hope you like this accordion and find it useful!
Awesome!
Thanks for sharing
Best regards from Brazil!
Great sliding. Good for one page template
Superb!!!!
Very slick ! Also browsing through her other articles, whoever this Mary Lou is, she has skills 🙂
Twitter handle ? (Would be nice if Codrops posted Twitter links for all of your authors — like SmashingMag does.)
You are incredible, i don’t know how you come up with & code these so fast 🙂
Very nice! Thank you for your great work!
Once again nice work, Mary Lou.
Perhaps it is a nice idea to make a fluid/flexible/responsive/you know jQuery slider for one of your next tutorials. I found a couple (really only 2 or 3) basic percentage based sliders on the net, but due to the popularity of responsive designs there’s a need for more 🙂
i am loving it
Really great work
Great work! Thank you.
I hate you guys 🙁 What you do makes me feel totally useless!
Mary Lou = My Hero
AMAZING work!!!
although do not know anything about jQuery …
every time a new article from here, always make all surprising 😉
so good so good ?
These tutorials are just very well done!! I Love you Mary Lou and love this site!
im waiting for this tutorial, thanks mary.. i should try this 🙂
Like This +1 ^_^
Keep up the wonderful work Mary =¤
Very nice graphical efect, but usability is poor 🙁
Great job dude, its wonderful 🙂
I hate coming to your site and your works cos [sobs 🙁 ]…I JUST CAN’T WALK AWAY…your works are to beautiful and awesome; holds me spell bound that I loose track of time. So you see…YOU DEFINITELY ARE A TEMPTATION!
Thanks with all my heart…Lou.
From NIGERIA.
Dammit, just thought of this as a awesome way for a new website and you guys beat me to it haha.
There is one minor bug in the fullscreen version, if you resize your window it doens’t resize to.
Could i use this code for my premium theme offcourse the source code credits stay in there.
Marry me Mary Lou! Exquisit work as ever.
Beautiful as always, keep up the great work. =)
very nice…;)
Thanks for another great tutorial Mary Lou, again you have built a beautifull piece of Jquery that any one would be proud of to include in their design. Keep up the good work! I look forward to your next post.
Really a nice featured list.
I guess example 2 and 5 will be really useful!
Continue with this good quality!
Is not the usual accordion! Congrats! Awesome!
Hi, Thanks for sharing such a great stuff and tutorial, is there any way to use the same code for horizontal Accordion thanks
Thanks Mary Lou. I have put this to use immediately.
I’m still fairly new to js and am not sure about the NoJs css file. Does this somehow only kick in if the reader has turned off JS? Or is it in case I want to use this design without JS? The values in NoJs file seem to be overriding the style.css when I tried to apply your tutorial.
Thanks
Great work, tnkx for share 😉
Good luck !
great tutorial
just one question, is it possible to leave out the arrow in the tutorial
Great plugin.
One way I think it could be better is by dynamically changing the width/height of the wrapper when the browser window resizes, making it more responsive. Any ideas how we could make that happen?
-Jacob
Great slide, thanks for sharig.
How I can transform it in horizontal? any idea? I´m interested about fullscreen example.
Best regards and thanks.
Great Plugin!
Very nice concept and very well executed.
Having problems in internet explorer…any answers?
I really want to install this on my site, but the accordion only shows my last image, right at the top. Any ideas?
Sorry, I don’t have a test site.
Great and thorough on your notes. I would quite like to do the fullscreen version but horizontally is this possible?
Great job….anyone can suggest me how to avoid that the slice close after click the menu (or click the slice area). I’d like to leave it open.
WAOn very nice creatively done. Can i use it for my commercial projects.
Hi
Is there a way to have this start on an open panel with faded in content?
I’m trying to remove the need for have someone click through the unexpanded sections, but can’t seem to figure out what to change in the JS.
Any help would be much appreciated!
Marc
How do I change the line-height on ?
Hi! Thank you, very much for this great script. Would be great if you’ll add an autoplay feature and a extra navigation menu. Thanks, again. 🙂
This is a beautiful accordion…
How do I adjust the line-height with cache.sliceH. I tried to set that from 50px to 1px, but there is no difference. It stays at 150px for line-height.
Let me know! Thanks!
Keep up the great work!
Norja
Hello Marie Lou,
Many thanks for your script. I’m trying to expand the first slide on load but didn’t find the way to do that. Did someone did it?
It´s possible to leave open the slide when click another?
Thanks
Very nice !
Is there anyway i can add a callback function on events?
Would it be possible for you to add an autoplay function to this?
Totally awesome great effects what about the browser compatibility ?
Example 2 (my favourite) errors and fails in IE8 – not that I like IE8 but some people will ahve it, is there a fix for this?
Also, Mary Lou used data() method (http://api.jquery.com/data/). This is quotation from docs: “Note that this method currently does not provide cross-platform support for setting data on XML documents, as Internet Explorer does not allow data to be attached via expando properties”.
Does anybody test the script in other version of IE?
Also, accordion has fixed height and weight in full screen example. So, if user change browser size, beauty will disappear.
I love the vertical sliding accordion on tympanus.net, can I also rename the jquery.vaccordion.js file?
http://forum.jquery.com/topic/can-i-edit-rename-a-jquery-file-from-within-dreamweaver
Great work here!
Any suggestions for making making the 5th example expand when the browser size is changed? Any help is much appreciated.
Thanks
Is there any way to have one of the slides in the open state? Something like $(‘#va-accordion’).vaccordion.selectSlice(2)..?