Home Tutorials Fonts Lists Freelance Web Designers List Feed RSSContact Me

Thursday, March 6, 2008

Liquid expandable section with mootools toggle effect

Save to delicious 0 hits

Adding Mootools effect to your pages you can make your site more attractive. Take a look at the toggle effect.

My friend Tom asked to me how to add the same mootools toggle effect (present on this post about Sliding top panel using mootools) to my previous post about liquid expandable section with rounded corners.


Live preview Download this tutorial

Step 1: HTML Code
HTML code is very simple (for more info and take a look here):

<h2><span>
<a href="#" id="toggle">My Section</a>
</span></h2>
<div id="section">
<div>
<!-- Your content here -->
</div>
</div>


Step 2: add mootools toggle effect
Add a link to mootools framework in the <head> tag of your page:

<script type="text/javascript" src="mootools.svn.js"></script>

... then add below the following code:

<script type="text/javascript">
window.addEvent('domready', function(){
var mySlide = new Fx.Slide('section');
$('toggle').addEvent('click', function(e){
e = new Event(e);
mySlide.toggle();
e.stop();
});
});
</script>

In this way, when an user click on the section header the section body will collapse top/down.

Download this tutorial


Related Content
Sliding top panel using mootools
Liquid expandable section with rounded corners using CSS

Sponsored Links
Share this post
Share on Facebook
Share on Twitter
Share on StumbleUpon
Share on Delicious
Share on Reddit
Share on Digg
Share on DesignFloat
Share on Technorati
Feeds RSS Subscribe to Feeds RSS
Old Comments
cssnewbie said...

Your third script example has a leading > which should be a <. Otherwise, great stuff! Very attractive result.

Antonio said...

@cssnewbie: Thanks!

Mini0n said...

I love this effect!
Awesome!

Anonymous said...

Nice work again Antonio!

But there's one thing that's even better w/ this effect. How can you add an image to this effect such as a minus sign when it's fully expanded and a plus sign when it's closed?

I'd appreciate any help you can provide.

Thanks!

Anonymous said...

What mootools components were used to create this?

Anonymous said...

Works great, looks great! How can I start with a closed section? Thanks! oli

Anonymous said...

mySlide.hide();

CE Stickrod said...

Can you change the orientation of the slide - i.e. horizontal?

Nikko said...

Example - some ideas for using it. I hope they like. Download Idea
I hope that can help them succeed or give you ideas for crer beautiful things even ams

diego jimenez said...

Can someone invert the process? How to do that the div despliege? (That is opened instead of being closed)

Thank you very much

Guifre said...

yes! is it possible to reverse the effect????

Kate said...

Is there anyway one can use it to toggle from the left to the right?

Wonderful tool otherwise!

george dickson said...

how do you create the reverse effect. as in you press the header the item drops down.

many thanks in advance

kashmir said...

How to reverse the effect?

About Me

I am Antonio Lupetti, Engineer, Pro Blogger, Mac user, Web addicted. Rome, IT.
Feeds RSS Contact Me

SubscribeFeeds RSS

Contact Me Enter your email address:

SubscribeLatest posts

SubscribeHot Links

Subscribe Design News

Apple Reviews and News
CSSRockstars - You Design, We Code. Your PSD to HTML/CSS for just $149