Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Design

Anthony Hind
Anthony Hind
5,715 Points

Change Page Effect

Hi all, I am creating a very simple layout left sidebar and right is the main content.

In the left side bar there will be a neat vertical NAV that will display different pages can anybody point me in the right direction to have a nice page effect when changing rather than just a normal page change the site is for a fellow student who just wants to display some photography projects on a nice simple elegant site.

So if i was to click project 1 in the nav the page would just fade in or out is this possible ??

Hope this makes sense :)

Regards

Anthony

10 Answers

Hey Anthony,

Depending on the effect you want, you might want to look for a plugin.

But if you want a simple fadeIn, you can do it with jQuery.

1st - You will want to reference to jQuery (include this in your page):

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js">        </script>

2nd - (I don't know how much you know about jQuery, but here is a simple solution) The code below checks to see if the page has loaded.

jQuery(document).ready(function($) { // the code below will run when the document has loaded. //(required!)// Code will go in here :)   });

3rd - Inside { } from the previous code. You will want to select your menu, for example if its called #menu. You do this in jQuery like so..

$("#menu").addClass('jqueryHidden').hide(); 

The reason I am adding a class to the menu, is because if a user has javascript turned off then the class won't be added. If the class is added successfully the menu will be hidden.

4th - Then you can select that class, only if the class is added will this code run.

$('.jqueryHidden').fadeIn();

Obviously this is a very simple example, so I hope this helps I will link a code pen as well. If you include this on each page, when the page loads the animation will run :)

Oh just to say in the parentheses of fadeIn( // here ); You can add in milliseconds how long you want the animation to be :)

See Example Here: http://codepen.io/anon/full/qdCno

Good Luck!!

Anthony Hind
Anthony Hind
5,715 Points

Hi Josh,

Thanks a lot for your help, that's the kind of set-up i'm after would it take much to get the <li></li> to display the different pages on selection would i just need to link to them? <li><a href="#about us"About us </li></a> <li><a href="#contact"</li></a> <li>Portfolio</li>

For example the fade in would be the content relevant to these pages using php includes for the header, sidebar and footer.

Thanks Again

Anthony

Anthony Hind
Anthony Hind
5,715 Points

Some of the code I posted didn't work correctly just spotted the markdown cheat sheet,

Hi Anthony,

I'm sorry I don't really understand. So do you want the animation on the page content not the Menu? So when you link on a link the content animates?

Sorry just trying to understand so I can answer :)

Anthony Hind
Anthony Hind
5,715 Points

Yes that's exactly what I'm after is that your work..

Cheers

Anthony

Hehe :) I wish! This is from codrops.com :) If you haven't already its well worth checking out :)

Here is the tutorial for that page animation:

http://tympanus.net/codrops/2012/01/30/page-transitions-with-css3/

Just remember this effect is using CSS3 so it won't work on every browser :)

Best of Luck!! ;)

Anthony Hind
Anthony Hind
5,715 Points

I would like to use the twitter bootstrap framework if possible and create a site that functions in this way i'm on such a tight timescale though as always :)

Well I wish you all the best :) Hope this helped :)

Anthony Hind
Anthony Hind
5,715 Points

It did thanks again....

Sometimes scouring the web and google you can't see the wood for the trees :)