Jquery-a navigation bar effect similar to flash, jquery-navigation bar

Source: Internet
Author: User

Jquery-a navigation bar effect similar to flash, jquery-navigation bar

Demo address: http://itxiaoming.sinaapp.com/demo05/demo.html

 

 

Html code
  1. <Html>
  2. <Head>
  3. <Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8">
  4. <Title> demo01 </title>
  5. <Link rel = "stylesheet" type = "text/css" href = "demo.css">
  6. <Script type = "text/javascript" src = "jquery. js"> </script>
  7. <Script type = "text/javascript" src = "demo. js"> </script>
  8. </Head>
  9. <Body>
  10. <Div id = "main">
  11. <Div class = "menu">
  12. <Div class = "menu_ B back1"> </div>
  13. <Span> test </span>
  14. </Div>
  15. <Div class = "menu">
  16. <Div class = "menu_ B back2"> </div>
  17. <Span> test </span>
  18. </Div>
  19. <Div class = "menu">
  20. <Div class = "menu_ B back3"> </div>
  21. <Span> test </span>
  22. </Div>
  23. <Div class = "menu">
  24. <Div class = "menu_ B back4"> </div>
  25. <Span> test </span>
  26. </Div>
  27. <Div class = "menu">
  28. <Div class = "menu_ B back5"> </div>
  29. <Span> test </span>
  30. </Div>
  31. <Div class = "menu">
  32. <Div class = "menu_ B back6"> </div>
  33. <Span> test </span>
  34. </Div>
  35. </Div>
  36. </Body>
  37. </Html>

 

 

Js Code
  1. $ (Document). ready (function (){
  2. $ (". Menu"). mouseover (function (){
  3. Var div = $ (this). children (". menu_ B ");
  4. Var span = $ (this). children ("span ");
  5. // Hide the font and move 20 Px to the right
  6. Span. stop (true, false). animate ({opacity: '0', left: '20px '}, 200 );
  7. // Display the background animation
  8. Div. stop (true, false ). animate ({width: '100px ', marginLeft:'-50px ', height: '1px', opacity: '1'}, 300 );
  9. Div. animate ({height: '40px ', marginTop:'-20px ', opacity: '1'}, 300 );
  10. // Display font, move 20 Px to the left
  11. Span. animate ({opacity: '1', left: '0p'}, 300 );
  12. Span.css ({color: '# fff '});
  13. });
  14. $ (". Menu"). mouseout (function (){
  15. Var div = $ (this). children (". menu_ B ");
  16. Var span = $ (this). children ("span ");
  17. // Hide the font and move 20 Px to the left
  18. Span. stop (true, false). animate ({opacity: '0', left: '20px '}, 200 );
  19. // Display the background animation
  20. Div. stop (true, false). animate ({height: '1px ', marginTop: '0px', opacity: '1'}, 300 );
  21. Div. animate ({width: '0px ', marginLeft: '0px', opacity: '1'}, 300 );
  22. // Display font, move 20 Px to the right
  23. Span. animate ({opacity: '1', left: '0p'}, 300 );
  24. Span.css ({color: '#777 '});
  25. });
  26. });

I wrote the animation effects based on my preferences. If you like the animation effects, you can change the effects on your own ..

 

Css code
  1. /* Demo01 css */
  2. # Main {
  3. Background: # EEE;
  4. Display: inline-block;
  5. Padding: 10px;
  6. }
  7. . Menu {position: relative;
  8. Width: 100px;
  9. Height: 40px;
  10. Margin: 10px auto;
  11. }
  12. . Menu_ B {
  13. Position: absolute;
  14. Width: 0px;
  15. Height: 0px;
  16. Background: red;
  17. Z-index: 1px;
  18. Top: 50%;
  19. Left: 50%;
  20. }
  21. . Menu span {
  22. Position: inherit;
  23. Display: block;
  24. Text-align: center;
  25. Line-height: 40px;
  26. Z-index: 3px;
  27. Font-size: 14px;
  28. Font-family: "Microsoft Yahei ";
  29. Color: #777;
  30. Cursor: pointer;
  31. }
  32. . Back1 {
  33. Background: # FF0000;
  34. }
  35. . Back2 {
  36. Background: # 921AFF;
  37. }
  38. . Back3 {
  39. Background: #00 CACA;
  40. }
  41. . Back4 {
  42. Background: #00DB00;
  43. }
  44. . Back5 {
  45. Background: # FF5809;
  46. }
  47. . Back6 {
  48. Background: # E1E100;
  49. }

 

  • Demo05.zip (33.2 KB)

High score: a standard imitation flash navigation bar written in js

<! DOCTYPE html PUBLIC "-// W3C // dtd xhtml 1.0 Strict // EN" "www.w3.org/TR/xhtml1/DTD/xhtml1-

Strict. dtd ">
<Html xmlns = "www.w3.org/5o/xhtml">
<Head>
<Meta http-equiv = "Content-Type" content = "text/html; charset = UTF-8"/>
<Title> navigation bar demonstration </title>
<Style type = "text/css" media = "all">
/* <! [CDATA [*/
Body {margin: 100px 0}
. Clear: after {content: "."; display: block; height: 0; clear: both; visibility: hidden}. clear

{Display: inline-block}. clear {display: block}
Div # nav {height: 70px; background: url (img/nav_bg.png) repeat-x}
Div # nav ul {width: 960px; margin: 0 auto; list-style: none}
Div # nav ul li {float: left; height: 35px; overflow: hidden; padding: 0 2px 0 0; font: bold 12px/35px

Arial; background: url (img/nav_right.png) repeat-y right 0}
Div # nav ul li a {float: left; height: 100%; padding: 0 20px; background: url (img/nav_sub.png) repeat-x;

Color: # fff; text-decoration: none}
Div # nav ul li a. hover {clear: both; background-position: 0-35px}
Div # nav ul li. on a {background-position: 0-35px}
Div # nav ul li. nobg {background: none}

H2 {text-align: center}
/*]> */
</Style>
</Head>

<Body>

<D ...... remaining full text>

Jquery is similar to the Flash effect navigation, but does not respond when you click the link

Open a new window:
<Li onClick = "window. open ('www .baidu.com ')"> <a href = "#"> Home </a> </li>
Original Window jump:
<Li onClick = "window. location. href = 'www .baidu.com '"> <a href = "#"> Plant a tree </a> </li>

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.