Best Free jQuery CSS Image Hover Effect Demos & Plugins

Ik Media group Ltd
jquery image hover effect

Today i am going to share  Free jQuery CSS Image Hover Effects with you that is pretty good.I came across quite a lot of CSS gallery websites that using huge thumbnail to showcase beautiful websites. Some of them are just ordinary thumbnail, but a lot of them have javascript animated caption to convey more information to viewers. In this tutorial, we will learn how to make ordinary thumbnail to something more. This is my second tutorial about thumbnail gallery, if you missed the first one, you might want to read it later -Downloading and demo links are given below. i also have given step by method of using this.

1. HTML


  1. <div class="zitem">

  2.     <a href="#"><img src="1.jpg" alt="Test 1" title="" width="125" height="125"/></a>

  3.     <div class="caption">

  4.         <a href="">Test 1</a>



  5.     </div>

  6. </div>



  7. <div class="zitem">

  8.     <a href="#"><img src="2.gif" alt="Test 2" title="" width="125" height="125"/></a>

  9.     <div class="caption">

  10.         <a href="">Test 2</a>



  11.     </div>

  12. </div>



  13. <div class="zitem">

  14.     <a href="#"><img src="3.png" alt="Test 3" title="" width="125" height="125"/></a>

  15.     <div class="caption">

  16.         <a href="">Test 3</a>



  17.     </div>

  18. </div>


2. CSS

I have added inline comment in the following CSS code. If you want to learn more about CSS, read my previous post 15 CSS Tips and Tricks or, you want to know MORE ABOUT CSS, read my new post - 15 Ways to Optimize CSS and Reduce CSS File Size

  1. .zitem {

  2.     width:125px;

  3.     height:125px;    

  4.     border:4px solid #222;    

  5.     margin:5px 5px 5px 0;

  6.     

  7.     /* required to hide the image after resized */

  8.     overflow:hidden;

  9.     

  10.     /* for child absolute position */

  11.     position:relative;

  12.     

  13.     /* display div in line */

  14.     float:left;

  15. }



  16. .zitem .caption {

  17.     width:125px;

  18.     height:30px;

  19.     background:#000;

  20.     color:#fff;

  21.         

  22.     /* fix it at the bottom */

  23.     position:absolute;

  24.     bottom:-1px; /* fix IE issue */

  25.     left:0;



  26.     /* hide it by default */

  27.     display:none;



  28.     /* opacity setting */

  29.     filter:alpha(opacity=70); /* ie */

  30.     -moz-opacity:0.7; /* old mozilla browser like netscape */

  31.     -khtml-opacity: 0.7; /* for really really old safari */

  32.     opacity: 0.7; /* css standard, currently it works in most modern browsers like firefox, */



  33. }



  34. .zitem .caption a {

  35.     text-decoration:none;

  36.     color:#fff;

  37.     font-size:12px;    

  38.     

  39.     /* add spacing and make the whole row clickable*/

  40.     padding:5px;

  41.     display:block;

  42. }



  43. img {

  44.     border:0;

  45.     

  46.     /* allow javascript moves the img position*/

  47.     position:absolute;

  48. }


3. Javascript

This is a simple jQuery script with hover effect. What we have to do is calculate the width and height and set it to the image.

  1.     

  2. $(document).ready(function() {



  3.     //move the image in pixel

  4.     var move = -15;

  5.     

  6.     //zoom percentage, 1.2 =120%

  7.     var zoom = 1.2;



  8.     //On mouse over those thumbnail

  9.     $('.zitem').hover(function() {

  10.         

  11.         //Set the width and height according to the zoom percentage

  12.         width = $('.zitem').width() * zoom;

  13.         height = $('.zitem').height() * zoom;

  14.         

  15.         //Move and zoom the image

  16.         $(this).find('img').stop(false,true).animate({'width':width, 'height':height, 'top':move, 'left':move}, {duration:200});

  17.         

  18.         //Display the caption

  19.         $(this).find('div.caption').stop(false,true).fadeIn(200);

  20.     },

  21.     function() {

  22.         //Reset the image

  23.         $(this).find('img').stop(false,true).animate({'width':$('.zitem').width(), 'height':$('.zitem').height(), 'top':'0', 'left':'0'}, {duration:100});    



  24.         //Hide the caption

  25.         $(this).find('div.caption').stop(false,true).fadeOut(200);

  26.     });



  27. });






0 Comment "Best Free jQuery CSS Image Hover Effect Demos & Plugins"

Post a Comment