17 2012
Musical drop down menu
Ares : Web- »
Musical drop down menu .

Skripter.info . .
Musical drop down menu


CSS3 + HTML5. CSS3 ( ). HTML5 javascript , .

1. HTML

, HTML . ( ) , :

01<ul id="nav">
02<li><a href="#">Menu element</a>
03<ul>
04<li><a href="#">Submenu element</a></li>
05.....
06</ul>
07</li>
08<li><a href="#">Menu 4</a></li>
09.....
10</ul>


2. CSS

CSS :

001#nav,#nav ul {
002list-style: none outside none;
003margin: 0;
004padding: 0;
005}
006#nav {
007font-family: "Lucida Sans Unicode",Verdana,Arial,sans-serif;
008font-size: 13px;
009height: 36px;
010list-style: none outside none;
011margin: 40px auto;
012text-shadow: 0 -1px 3px #202020;
013width: 700px;
014
015/* border radius */
016-moz-border-radius: 4px;
017-webkit-border-radius: 4px;
018border-radius: 4px;
019
020/* box shadow */
021-moz-box-shadow: 0px 3px 3px #cecece;
022-webkit-box-shadow: 0px 3px 3px #cecece;
023box-shadow: 0 3px 4px #8b8b8b;
024
025/* gradient */
026background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #787878), color-stop(0.5, #5E5E5E), color-stop(0.51, #707070), color-stop(1, #838383));
027background-image: -moz-linear-gradient(center bottom, #787878 0%, #5E5E5E 50%, #707070 51%, #838383 100%);
028background-color: #5f5f5f;
029}
030#nav li {
031border-bottom: 1px solid #575757;
032border-left: 1px solid #929292;
033border-right: 1px solid #5d5d5d;
034border-top: 1px solid #797979;
035display: block;
036float: left;
037height: 34px;
038position: relative;
039width: 105px;
040}
041#nav > li:first-child {
042border-left: 0 none;
043margin-left: 5px;
044}
045#nav ul {
046left: -9999px;
047position: absolute;
048top: -9999px;
049z-index: 2;
050}
051#nav ul li {
052background: none repeat scroll 0 0 #838383;
053box-shadow: 5px 5px 5px rgba(0, 0, 0, 0.5);
054width: 100%;
055}
056#nav li a {
057color: #FFFFFF;
058display: block;
059line-height: 34px;
060outline: medium none;
061text-align: center;
062text-decoration: none;
063
064/* gradient */
065background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #787878), color-stop(0.5, #5E5E5E), color-stop(0.51, #707070), color-stop(1, #838383));
066background-image: -moz-linear-gradient(center bottom, #787878 0%, #5E5E5E 50%, #707070 51%, #838383 100%);
067background-color: #5f5f5f;
068}
069
070/* keyframes #animation */
071@-webkit-keyframes animation {
0720% {
073-webkit-transform: scale(1);
074}
07530% {
076-webkit-transform: scale(1.2);
077}
078100% {
079-webkit-transform: scale(1.1);
080}
081}
082@-moz-keyframes animation {
0830% {
084-moz-transform: scale(1);
085}
08630% {
087-moz-transform: scale(1.2);
088}
089100% {
090-moz-transform: scale(1.1);
091}
092}
093#nav li > a:hover {
094/* CSS3 animation */
095-webkit-animation-name: animation;
096-webkit-animation-duration: 0.3s;
097-webkit-animation-timing-function: linear;
098-webkit-animation-iteration-count: 1;
099-webkit-animation-direction: normal;
100-webkit-animation-delay: 0;
101-webkit-animation-play-state: running;
102-webkit-animation-fill-mode: forwards;
103
104-moz-animation-name: animation;
105-moz-animation-duration: 0.3s;
106-moz-animation-timing-function: linear;
107-moz-animation-iteration-count: 1;
108-moz-animation-direction: normal;
109-moz-animation-delay: 0;
110-moz-animation-play-state: running;
111-moz-animation-fill-mode: forwards;
112}
113#nav li:hover ul {
114left: 0;
115top: 34px;
116width: 150px;
117}


, () .

3. HTML5 javascript

. , , , , :


01// variables
02var aLoops = []; // sound loops
03
04// initialization
05addEvent(window, 'load', function (event) {
06
07// load music files
08aLoops[0] = new Audio('media/background.ogg');
09aLoops[0].volume = 0.3;
10aLoops[1] = new Audio('media/button.ogg');
11aLoops[1].volume = 1.0;
12aLoops[2] = new Audio('media/button_click.ogg');
13aLoops[2].volume = 1.0;
14
15aLoops[0].addEventListener('ended', function() { // loop background sound
16this.currentTime = 0;
17this.play();
18}, false);
19aLoops[0].play();
20});


: mouseover, mouseout and click:

01// all the buttons
02var aBtns = document.querySelectorAll('#nav li');
03
04// onmouseover event handler
05addEvent(aBtns, 'mouseover', function (event) {
06aLoops[1].currentTime = 0;
07aLoops[1].play(); // play click sound
08});
09
10// onmouseout event handler
11addEvent(aBtns, 'mouseout', function (event) {
12aLoops[1].currentTime = 0;
13aLoops[1].pause(); // play click sound
14});
15
16// onclick event handler
17addEvent(aBtns, 'click', function (event) {
18aLoops[2].currentTime = 0;
19aLoops[2].play(); // play click sound
20});


, !


: script-tutorials.com/musical-drop-down-menu
: Ares ( Skripter.info )



! .










, .
.
sssR | 18 2012 10:58 | (1|0)
  • : |
  • : 1 ()

18


, , .