The special effects on the homepage of Netease news are very nice. I wrote a special effect on the webpage last week. I wanted to imitate the effect of Netease news this morning, and I finally finished it in the afternoon.
Effect:
1. Normally, images and text are rotated. You can modify ContentN. Html (N = 1 ~ 6) content in the file;
2. Move the mouse to the big image and stop the rotation. You can click to browse left or right, or click a small image to browse;
3. Small images and left and right click-on translucent images. You can set the focus image style at will;
4. You can freely move the effect to other webpages.
The following code is used: <Head> <title> animations on the Netease homepage </title>
<Style type = text/css>
Body {text-align: center;
Topmargin: 0;
Leftmargin: 0;
Background: yellow ;}
# Dawn0919 {position: relative;
Text-align: center;
Topmargin: 0;
Leftmargin: 0;
Red;
Width: 1024;
Height: 500;
Border: 0;
Overflow: hidden;
Z-index: 1 ;}
# Dawn0718 {position: absolute;
Left: 464;
Top: 0;
Text-align: center;
Topmargin: 0;
Leftmargin: 0;
Width: 560px;
Height: 280px;
Border: 0;
Blue;
Overflow: hidden;
Z-index: 2 }# Content0 {position: absolute;
Left: 0;
Z-index: 3
}
# Content1 {position: absolute;
Left: 560;
Z-index: 4
}
# Content2 {position: absolute;
Left: 1120;
Z-index: 5
}
# Content3 {position: absolute;
Left: 1680;
Z-index: 6
}
# Content4 {position: absolute;
Left: 2240;
Z-index: 7
}
# Content5 {position: absolute;
Left: 2800;
Z-index: 8
} # MidBtn {position: absolute;
Width: 400;
Height: 50;
Top: 108;
Left: 0;
Z-index: 718;
Filter: alpha (opacity = 70 );
}
# LeftBtn {position: absolute;
Top: 0;
Left: 18;
Z-index: 719;
Filter: alpha (opacity = 60 );
} # RightBtn {position: absolute;
Top: 0;
Left: 342;
Z-index: 780;
} # BottomPicBtn {position: absolute;
Width: 400;
Height: 50;
Top: 228;
Left: 0;
Z-index: 9999;
Filter: alpha (opacity = 70 );
}
# SmallPic0 {position: absolute;
Width: 59;
Height: 42;
Top: 2;
Left: 12;
Border-width: 0;
Margin: 2px 2px auto;
}
# SmallPic1 {position: absolute;
Width: 59;
Height: 42;
Top: 2;
Left: 76;
Border-width: 0;
Margin: 2px 2px auto;
}
# SmallPic2 {position: absolute;
Width: 59;
Height: 42;
Top: 2;
Left: 140;
Border-width: 0;
Margin: 2px 2px auto;
}
# SmallPic3 {position: absolute;
Width: 59;
Height: 42;
Top: 2;
Left: 204;
Border-width: 0;
Margin: 2px 2px auto;
}
# SmallPic4 {position: absolute;
Width: 59;
Height: 42;
Top: 2;
Left: 268;
Border-width: 0;
Margin: 2px 2px auto;
}
# SmallPic5 {position: absolute;
Width: 59;
Height: 42;
Top: 2;
Left: 332;
Border-width: 0;
Margin: 2px 2px auto;
}
. PicFocus {position: absolute;
Margin: 2px 2px 2px 2px;
Border-width: 4;
Border-style: solid;
Border-color: white;
Background: white;
}
</Style> <script language = javascript type = text/javascript> var ScrollStr;
Var ScrollWidth = 560;
Var ScrollNumBers = 6;
Var TimerID;
Var ActionFlag = 0; function init (){
ScrollStr = "012345 ";
ReadyDiv ();
HideBottomPicBtn ();
} Function ReadyDiv (){
For (var I = 0; I <ScrollNumBers; I ++ ){
Var DivTemp = document. getElementById ("Content" + ScrollStr. substring (I, I + 1). style;
DivTemp. xpos = (I-1) * ScrollWidth;
DivTemp. left = DivTemp. xpos + 'px ';
Document. getElementById ("SmallPic" + I). className = "SmallPic" + I. toString ();
}
Document. getElementById ("SmallPic" + ScrollStr. substring (1, 2). className = "PicFocus ";
} Function ScrollPicToLeft (){
ScrollStr = ScrollStr. substring (1, ScrollNumBers) + ScrollStr. substring (0, 1 );
ReadyDiv ();
} Function ScrollPicToRight (){
ScrollStr = ScrollStr. substring (ScrollNumBers-1, ScrollNumBers) + ScrollStr. substring (0, ScrollNumBers-1 );
ReadyDiv ();
} Function ShowBottomPicBtn (){
StopSwith ();
Var PspMidBtn = document. getElementById ("MidBtn ");
PspMidBtn. style. visibility = "visible"; var PspBottomPicBtn = document. getElementById ("BottomPicBtn ");
PspBottomPicBtn. style. visibility = "visible ";
} Function HideBottomPicBtn (){
Var PspMidBtn = document. getElementById ("MidBtn ");
PspMidBtn. style. visibility = "hidden"; var PspBottomPicBtn = document. getElementById ("BottomPicBtn ");
PspBottomPicBtn. style. visibility = "hidden ";
TimerStart ();
} Function ScrollToPic (StrPicID ){
Var IFind = ScrollStr. indexOf (StrPicID );
ScrollStr = ScrollStr. substring (IFind, ScrollNumBers) + ScrollStr. substring (0, IFind );
ScrollPicToRight ();
ReadyDiv ();
} Function TimerStart () {if (ActionFlag = 0 ){
ActionFlag = 1;
TimerID = window. setInterval (ScrollPicToLeft, 3000 );}
}
Function StopSwith () {ActionFlag = 0;
Window. clearInterval (TimerID );
}
Window.
Init ();
TimerStart ();
}
</Script>
<Body topmargin = "0" leftmargin = "0" rightmargin = "0" bottommargin = "0">
<Div id = dawn0919>
<Div id = dawn0718 onMouseOut = "HideBottomPicBtn ()" onMouseOver = "ShowBottomPicBtn ()">
<Div ID = One>
<Iframe id = "Content0" src = "html/Content1.htm" frameborder = "0" scrolling = "0" border = "0" width = "560" height = "280"> </iframe>
</Div>
<Div ID = Two>
<Iframe id = "Content1" src = "html/Content2.htm" frameborder = "0" scrolling = "0" border = "0" width = "560" height = "280"> </iframe>
</Div>
<Div ID = Three>
<Iframe id = "Content2" src = "html/Content3.htm" frameborder = "0" scrolling = "0" border = "0" width = "560" height = "280"> </iframe>
</Div>
<Div ID = Four>
<Iframe id = "Content3" src = "html/Content4.htm" frameborder = "0" scrolling = "0" border = "0" width = "560" height = "280"> </iframe>
</Div>
<Div ID = Five>
<Iframe id = "Content4" src = "html/Content5.htm" frameborder = "0" scrolling = "0" border = "0" width = "560" height = "280"> </iframe>
</Div>
<Div ID = Six>
<Iframe id = "Content5" src = "html/Content6.htm" frameborder = "0" scrolling = "0" border = "0" width = "560" height = "280"> </iframe>
</Div>
<Div ID = MidBtn>
</Div>
<Div ID = BottomPicBtn>
<Div class = PicFocus ID = SmallPic0> </div>
<Div class = PicFocus ID = SmallPic1> </div>
<Div class = PicFocus ID = SmallPic2> </div>
<Div class = PicFocus ID = SmallPic3> </div>
<Div class = PicFocus ID = SmallPic4> </div>
<Div class = PicFocus ID = SmallPic5> </div>
</Div>
</Div>
</Div>
</Body>
</Html>: 650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131228/12031T124-0.jpg "/>
This article is from the "CSharp" blog, please be sure to keep this source http://dawn0919.blog.51cto.com/2954252/1128059