jquery picture Silhouette Fadeins Fade effect _jquery

Source: Internet
Author: User
Several friends of my band have just undergone a change in the small membership lineup. They need to replace the photos on their home page. I think it might be interesting to have a little interaction with something.

There may be many ways to do this, and this one just came into my head and suddenly appeared, and I went with it. The idea is to have a silhouette as a background image, then, in the group all exactly the same size with each band member's 4 images. These images are hidden by default. Then, there are 4 absolutely-positioned regions above the region, which is the transition zone role. In jquery, we use them to hover over events, gradually displaying the corresponding images.


Html
As I said, it's just a div with four images and a transition area. All have unique IDs and a common class class name.

Copy Code code as follows:

<div id= "Home-photos-box" >

<a id= "aller" href= "#aller" class= "Home-roll-box" ></a>
<a id= "Neil" href= "#neil" class= "Home-roll-box" ></a>
<a id= "Aaron" href= "#aaron" class= "Home-roll-box" ></a>
<a id= "Scott" href= "#scott" class= "Home-roll-box" ></a>


</div>



Css
The class name covers commonalities (such as location styles), followed by IDs (including specific left position).
Copy Code code as follows:

#home-photos-box {float:left; width:352px; Background:url (. /images/guys-allblack.png) No-repeat; padding:334px 0 0 0; position:relative; }
#aller {left:0;}
#neil {left:25%;}
#aaron {left:50%;}
#scott {left:75%;}
. home-roll-box {position:absolute; z-index:1000; display:block; height:334px; top:0; width:25%;}
. single-guy {position:absolute; top:0; left:0; display:none; opacity:0;}



Jquery
When the mouse hovers over the corresponding area, which corresponds to the ID and fade of the image, use Stop () to prevent the animations queued here and we use opaque settings. Fadetoggle (), when too fast and the mouse moves to fade.
Copy Code code as follows:

$ (function () {
var name = "";
$ (". Home-roll-box"). Hover (function () {
Name = $ (this). attr ("id");
$ ("#image-" +name). Stop (). Show (). Animate ({opacity:1});
}, function () {
Name = $ (this). attr ("id");
$ ("#image-" +name). Stop (). Animate ({opacity:0});
});
});

Download Address http://www.jb51.net/jiaoben/24272.html

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.