初學網頁,確實對於一些特效不是很懂,尤爲對我只是在W3C上學過一點點皮毛的人,實際上網上有不少關於js特效的素材網站,我的收集以下:javascript
http://www.drame.cn/javascript/css
http://down.admin5.com/texiao/java
http://www.lanrentuku.com/js/ide
http://www.kaiwo123.com/函數
http://sc.chinaz.com/jiaoben/網站
若是你能熟知各類特效的名稱其實直接百度或者谷歌均可以找到相關代碼,本文是關於口風琴是導航欄,代碼參看的網上。this
js代碼以下:spa
function initMenu() { $('#menu ul').hide(); $('#menu ul').children('.current').parent().show();/*默認顯示*/ $('#menu ul:first').show();//first,second顯示那個ul $('#menu li a').click( function () { var checkElement = $(this).next(); if ((checkElement.is('ul')) && (checkElement.is(':visible'))) { return false; } if ((checkElement.is('ul')) && (!checkElement.is(':visible'))) { $('#menu ul:visible').slideUp('normal'); checkElement.slideDown('normal'); return false; } } ); } $(document).ready(function () { initMenu(); });//頁面加載時執行函數
初學我困擾於如何在頁面加載是在js中寫函數,以上代碼給了一個很好的示範。code
css樣式代碼以下:orm
body { font-family: Helvetica, Arial, sans-serif; font-size: 0.9em; } p { line-height: 1.5em; } ul#menu, ul#menu ul { list-style-type:none; margin: 0; padding: 0; width: 15em; } ul#menu a { display: block; text-decoration: none; } ul#menu li { margin-top: 1px; } ul#menu li a { background: #333; color: #fff; padding: 0.5em; } ul#menu li a:hover { background: #000; } ul#menu li ul li a { background: #ccc; color: #000; padding-left: 20px; } ul#menu li ul li a:hover,ul#menu li ul .current a { background: #aaa; border-left: 5px #000 solid; padding-left: 15px; } .code { border: 1px solid #ccc; list-style-type: decimal-leading-zero; padding: 5px; margin: 0; } .code code { display: block; padding: 3px; margin-bottom: 0; } .code li { background: #ddd; border: 1px solid #ccc; margin: 0 0 2px 2.2em; } .indent1 { padding-left: 1em; } .indent2 { padding-left: 2em; }
aspx代碼以下(基本原理就是類表中嵌套列表):
<ul id="menu"> <li> <a href="#">Weblog Tools</a> <ul> <li><a href="javascript:void(0)">PivotX</a></li> <li><a href="javascript:void(0)">WordPress</a></li> <li><a href="javascript:void(0)">Textpattern</a></li> <li><a href="javascript:void(0)">Typo</a></li> </ul> </li> <li> <a href="#">Programming Languages</a> <ul> <li class="current"><a href="javascript:void(0)">PHP</a></li> <li><a href="javascript:void(0)">Ruby</a></li> <li><a href="javascript:void(0)">Python</a></li> <li><a href="javascript:void(0)">PERL</a></li> <li><a href="javascript:void(0)">Java</a></li> <li><a href="javascript:void(0)">C#</a></li> </ul> </li> <li><a href="#">Marco's blog (no submenu)</a> <ul> <li><a href="javascript:void(0)">Apple</a></li> <li><a href="javascript:void(0)">Nikon</a></li> <li><a href="javascript:void(0)">XBOX360</a></li> <li><a href="javascript:void(0)">Nintendo</a></li> </ul> </li> <li> <a href="#">Cool Stuff</a> <ul> <li><a href="javascript:void(0)">Apple</a></li> <li><a href="javascript:void(0)">Nikon</a></li> <li><a href="javascript:void(0)">XBOX360</a></li> <li><a href="javascript:void(0)">Nintendo</a></li> </ul> </li> <li> <a href="#">Search Engines</a> <ul> <li><a href="javascript:void(0)">Yahoo!</a></li> <li><a href="javascript:void(0)">Google</a></li> <li><a href="javascript:void(0)">Ask.com</a></li> <li><a href="javascript:void(0)">Live Search</a></li> </ul> </li> </ul>