Today i am going to share Free jQuery CSS Image Hover Effects amongst y'all 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 only ordinary thumbnail, but a lot of them select javascript animated caption to bring to a greater extent than data to viewers. In this tutorial, nosotros volition acquire how to brand ordinary thumbnail to something more. This is my 2d tutorial well-nigh thumbnail gallery, if y'all missed the showtime one, y'all powerfulness desire to read it after -Downloading in addition to demo links are given below. i equally good select given measuring past times method of using this.
1. HTML
- <div class="zitem">
- <a href="#"><img src="1.jpg" alt="Test 1" title="" width="125" height="125"/></a>
- <div class="caption">
- <a href="">Test 1</a>
- </div>
- </div>
- <div class="zitem">
- <a href="#"><img src="2.gif" alt="Test 2" title="" width="125" height="125"/></a>
- <div class="caption">
- <a href="">Test 2</a>
- </div>
- </div>
- <div class="zitem">
- <a href="#"><img src="3.png" alt="Test 3" title="" width="125" height="125"/></a>
- <div class="caption">
- <a href="">Test 3</a>
- </div>
- </div>
2. CSS
I select added inline comment inward the next CSS code. If y'all desire to acquire to a greater extent than well-nigh CSS, read my previous post 15 CSS Tips in addition to Tricks or, y'all desire to know MORE ABOUT CSS, read my novel transportation service - 15 Ways to Optimize CSS in addition to Reduce CSS File Size
- .zitem {
- width:125px;
- height:125px;
- border:4px solid #222;
- margin:5px 5px 5px 0;
- /* required to cover the ikon after resized */
- overflow:hidden;
- /* for small-scale fry absolute seat */
- position:relative;
- /* display div inward trouble */
- float:left;
- }
- .zitem .caption {
- width:125px;
- height:30px;
- background:#000;
- color:#fff;
- /* cook it at the bottom */
- position:absolute;
- bottom:-1px; /* cook IE number */
- left:0;
- /* cover it past times default */
- display:none;
- /* opacity setting */
- filter:alpha(opacity=70); /* ie */
- -moz-opacity:0.7; /* former mozilla browser similar netscape */
- -khtml-opacity: 0.7; /* for actually truly former safari */
- opacity: 0.7; /* css standard, currently it industrial plant inward most modern browsers similar firefox, */
- }
- .zitem .caption a {
- text-decoration:none;
- color:#fff;
- font-size:12px;
- /* add together spacing in addition to brand the whole row clickable*/
- padding:5px;
- display:block;
- }
- img {
- border:0;
- /* let javascript moves the img position*/
- position:absolute;
- }
3. Javascript
This is a uncomplicated jQuery script amongst hover effect. What nosotros select to create is calculate the width in addition to tiptop in addition to laid it to the image.
- $(document).ready(function() {
- //move the ikon inward pixel
- var deed = -15;
- //zoom percentage, 1.2 =120%
- var zoom = 1.2;
- //On mouse over those thumbnail
- $('.zitem').hover(function() {
- //Set the width in addition to tiptop according to the zoom percentage
- width = $('.zitem').width() * zoom;
- height = $('.zitem').height() * zoom;
- //Move in addition to zoom the image
- $(this).find('img').stop(false,true).animate({'width':width, 'height':height, 'top':move, 'left':move}, {duration:200});
- //Display the caption
- $(this).find('div.caption').stop(false,true).fadeIn(200);
- },
- function() {
- //Reset the image
- $(this).find('img').stop(false,true).animate({'width':$('.zitem').width(), 'height':$('.zitem').height(), 'top':'0', 'left':'0'}, {duration:100});
- //Hide the caption
- $(this).find('div.caption').stop(false,true).fadeOut(200);
- });
- });
0 comments: