Jquery-based ction image gradient animation effect

Source: Internet
Author: User

Another aspect is the use of filters. However, it must be noted that filters cannot be identified in firefox,
Let's start coding.
Html is relatively simple
Code
Copy codeThe Code is as follows:
<! Doctype html public "-// W3C // dtd html 4.0 Transitional // EN">
<Html>
<Head>
<TITLE> myjquerydirection </TITLE>
<META http-equiv = content-type content = "text/html; charset = gb2312">
<Link rel = "stylesheet" type = "text/css" href = "css/dirction.css">
<Script language = javascript src = "js/jquery. js" type = "text/javascript"> </script>
<Script type = "text/javascript" src = "js/drection. js"> </script>
</Head>
<Body>
<Div id = nav>
<Ul>
<Li>
<Div> An island </div> </li>
<Li>
<Div> A wheat spike </div> </li>
<Li>
<Div> one tree of green leaves </div> </li>
<Li>
<Div> a big tree </div> </li>
<Li>
<Div> sunflower </div> </li> </ul>
<Div id = frontTextBack> </div>
<Div id = frontText> </div>
<Div id = frontTextSub> </div>
<Div id = BG> </div>
<Div id = mask> </div>
<Div id = back>
</Div>
</Body>
</Html>

Here there are multiple div tag id = frontTextBack labels that are used to display the shadow through the css Filter. There is nothing to say about other codes.
Now we have written our css code.
Write at the top level
Code
Copy codeThe Code is as follows:
Body {padding: 0;
Moz-user-select: none;
Margin: 0;
}
# Nav {background: url ("loadsmall.gif") no-repeat scroll 330px 100px #000;
Height: 240px;
Overflow: hidden;
Position: relative;
Width: 760px;
Display: block;
}
# Nav ul {bottom: 0px;
Left: 3px;
Position: absolute;
Text-align: left;
Z-index: 999;
}
# Nav ul li {list-style: none;
Display: block;
Float: left;
Height: 50px;
Width: 140px;
Font-size: 12px;
Position: relative;
}
# Nav li img {border: 1px solid white;
Cursor: pointer;
Float: left;
Height: 35px;
Left: 10px;
Top: 5px;
Width: 52px;
Margin-top: 10px;
}
# Nav li div {FILTER: alpha (opacity = 60 );
Margin-left: 70px;
Margin-top: 5px;
Padding-left: 10px;
Color: white;
}
# FrontTextBack {color: #000;
Font-family: Verdana;
Font-size: 30px;
Left: 22px;
Position: absolute;
Width: 100%;
Top: 22px;
}
# FrontText {color: # fff;
Font-size: 30px;
Font-weight: 900;
Left: 20px;
Position: absolute;
Top: 20px;
Width: 100%;
Z-index: 999;
}
# FrontTextSub {color: # fff;
Font-size: 13px;
Left: 25px;
Position: absolute;
Top: 60px;
Width: 100%;
}
# BG {background: none repeat scroll 0 0 #000;
Border-top: 1px solid #999;
Bottom: 0;
Height: 50px;
Position: absolute;
Text-align: right;
Width: 100%;
}
# Mask {background: repeat scroll 0 0 transparent;
Height: 100%;
Position: absolute;
Width: 100%;
Z-index: 990;
}
# Back {text-align: center;
}
. Gray {FILTER: gray ();} // set the FILTER to gray.

The next step is to compile js
Code
Load
Copy codeThe Code is as follows:
$ (Function (){
// First find the img to be clicked
$ ("Li img"). click (function (){
// Determine whether the current img has been clicked
If (this. className. indexOf ("active ")! =-1)
{
Return;
}
// Obtain data
Var I = $ (this). attr ("pic ");
// Obtain the text to be displayed and split the text into an Array Using |
Var t = $ (this). attr ("text"). split ("| ");
// Change the fade-out of text and adjust the animation effect by controlling the transparency.
$ ("# FrontText"). fadeOut ();
$ ("# FrontTextBack"). fadeOut ();
$ ("# FrontTextSub"). fadeOut ();
// Process the current active img and restore it to its original state
$ ("Li img. active"). animate ({top: 5, width: 52, left: 10}, 300)
. RemoveClass ("active ")
. FadeTo (200, 0.6)
// Process the current active img
$ (This). animate ({top:-5, width: 40, height: 70, left: 1}, 300)
. AddClass ("active ")
. FadeTo (200,1)
// Process the big image of the displayed div
$ ("# Back"). children (). addClass ("gray"). end ()
. FadeIn (500, 0.1, function (){
$ (This). children ("img"). attr ("src", "imgaes/" + I + ". jpg"). removeClass ("gray ");
$ (This). fadeTo (500,1, function (){
$ ("# FrontText" ).html (t [0]). fadeIn (200); // modify the text
$ ("# FrontTextBack" ).html (t [0]). fadeIn (200); // shadow text
$ ("# FrontTextSub" ).html (t [1]). fadeIn (200)} // subtitle
);
});
});
});
// Initialize the first image
Var I = 0;
Show ();
Function show (){
If (I = $ ("li img"). size () I = 0
$ ("Li img"). eq (I). click ();
I ++;
// SetTimeout (show (), 1000 );
}

Related Article

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.