Subscribe to our feed...

http://feeds.feedburner.com/design-notes

  • Push Your Designs To Perfection

    goldSCHNITT is a small stand alone application for MAC that helps you apply golden ration to your design. Golden ratio(1.61803) is believed as a ratio of perfection. It has been used by many artists and architects through the history.

    Now we have this small app called goldSCHNITT to help you implement golden ration into your design.

Make Your Header Responses To Mouse Movements with jParallax

Under: jQuery 70 comments

jParallax is no news to jQuery lovers. For those who still dont know anything about it. Here is a little introduction.

jParallax turns a selected element into a ‘window’, or viewport, and all its children into absolutely positioned layers that can be seen through the viewport. These layers move in response to the mouse, and, depending on their dimensions (and options for layer initialisation), they move by different amounts, in a parallaxy kind of way.

Next, I will show you how to make a beautiful header that response to mouse movements. My portfolio site uses this trick, so you can see the result first.

Linking javascripts

<script src="js/jquery-1.3.2.js" type="text/javascript"><!--mce:0--></script>
<script src="js/jquery.lightbox-0.5.min.js" type="text/javascript"><!--mce:1--></script>
<script src="js/jquery.jparallax.js" type="text/javascript"><!--mce:2--></script>

HTML and CSS code.

Setup the window, give its id name parallax and width, so only this area responses to mouse movements. As the diagram shows above, the image you list first goes to the back.
Make sure the width is set properly to prevent collapsing view point. If any of the layer travels outside the parallax window, it will be hidden.

<div id="parallax"> <img style="width: 400px;" src="images/0.png" alt="" />
<img style="width: 500px;" src="images/1.png" alt="" />
<img style="width: 600px;" src="images/2.png" alt="" />
<img style="width: 550px;" src="images/3.png" alt="" /></div>

CSS

#parallax
    {position:relative; overflow:hidden; width:800px; height:450px;border:none;
	margin:0 auto 20px auto;}

My image 0

My image 1

My image 2

My image 3

Basic JavaScripts

jQuery(document).ready(function(){
	jQuery('#parallax').();
});

This is the result with default settings. As you can see, it is a bit weird.

Use Layers option

jQuery(‘element’).jparallax(options, layer_0_options, layer_1_options, etc.);

I disabled the Y axis movement and gave travel range to layer 0 (image 0) and layer 1(image 1). Now I have a nice ocean view header!!

jQuery(document).ready(function(){
	jQuery('#parallax').jparallax({yparallax:false},{xtravel: '100px'},{xtravel: '300px'});
});
ADD TOAdd To Evernote

If this helps, why not tell your friends?

  • Reddit
  • del.icio.us
  • StumbleUpon
  • Facebook
  • Technorati
  • Design Float
  • Identi.ca
  • FriendFeed
  • Yahoo! Buzz
  • Ping.fm

70 Responses to “ Make Your Header Responses To Mouse Movements with jParallax ”

  • arnaud-k says:

    Nice tutorial.

    I really like this JQuery plugin. I used it to make my portfolio header ( http://arnaud-k.fr ).

    [Reply]

  • Kawsar Ali says:

    This is a very cool effect. I have seen on many sites and wondered. Thanks for explaining.
    Kawsar Ali´s last blog ..35 Excellent Websites for Downloading Free CSS Template

    [Reply]

  • Quite interesting and dummie-friendly :)

    [Reply]

  • WAMPvn says:

    Very nice application. i can get starting re-designing my website.
    WAMPvn´s last blog ..?ánh giá 2 smartphone bom t?n: Omnia và Xperia X1

    [Reply]

  • WAMPvn says:

    Very nice application. i can get starting re-designing my website.
    WAMPvn´s last blog ..?ánh giá 2 smartphone bom t?n: Omnia và Xperia X1

    [Reply]

  • WAMPvn says:

    Very nice application. i can get starting re-designing my website.

    [Reply]

  • Efe Cosan says:

    I’ve noticed a problem with this tutorial. I’ve not seen it in another jParallax example.

    In your tutorial’s result page, if you resize the page, the island and birds may become hidden or flashing. Do you know what is the reason? I’ve same kind of problem with my work which is not online yet, too. What can be the problem?

    [Reply]

  • Efe Cosan says:

    I’ve found the problem.

    It’s because of pixel values for travel options. If you enter travel values as percent you can solve the problem.

    I’ve informed the author of plugin about the problem.

    [Reply]

    alexandra Reply:

    My portfolio site was temporary down for bandwidth reason. It is up now

    [Reply]

  • Marco says:

    jParallax dev by:stephband.info (‘problem when resizing window if travel set in ‘px’) Here the fixed version with the original license http://www.h2osoft.it/jquery.jparallax.js

    Ho fatto un fix che per la mia necessità va bene(anche quando ridimensiono il browser e ho dato i valori in PX nn impazzisce)

    Non appena mi risponde stephband gli mando il fix e deciderà se pubblicarlo

    [Reply]

  • Davey says:

    Awesome tutorial, great plugin. Well done
    Davey´s last blog ..Threadless Tshirt Giveaway at jaypeeonline.net

    [Reply]

  • abant says:

    This is a very cool effect. I have seen on many sites and wondered , thanks for sharing…

    [Reply]

  • A clever way to design I must say ;)

    [Reply]

  • webb says:

    I would have thought only flash could create an effect like that, It’s really cool.

    [Reply]

  • MYO HAN HTUN says:

    Great post. I really like it. The effects are very cool.

    [Reply]

  • Indialike says:

    Very nice and useful tutorials for web designers,
    Thanks for posting.

    [Reply]

  • Nemke says:

    This is a very cool effect. Very nice and useful tutorials.
    Thanks for posting.

    [Reply]

  • Leave a Reply

    All fields marked with "*" are required.