找回密码
 注-册

QQ登录

只需一步,快速开始

查看: 1444|回复: 0

[特效] 一个比较实用的导航菜单

[复制链接]
Leya 发表于 2008-3-31 11:18:28 | 显示全部楼层 |阅读模式
  1. <style type="text/css">
  2. <!--
  3. .titleStyle{
  4. background-color:#FFCC99;color:#006699;border-top:1px solid #FFFFFF;font-size:9pt;cursor:hand;
  5. }
  6. .contentStyle{
  7. background-color:#eeffee;color:blue;font-size:9pt;
  8. }
  9. -->
  10. </style>


  11. <script language="JavaScript">
  12. <!--
  13. var layerTop=267; //菜单顶边距
  14. var layerLeft=840; //菜单左边距
  15. var layerWidth=150; //菜单总宽
  16. var titleHeight=30; //标题栏高度
  17. var contentHeight=300; //内容区高度
  18. var stepNo=10; //移动步数,数值越大移动越慢

  19. var itemNo=0;runtimes=0;
  20. document.write('<span id=itemsLayer style="position:absolute;overflow:hidden;border:1px solid #008800;left:'+layerLeft+';top:'+layerTop+';width:'+layerWidth+';">');

  21. function addItem(itemTitle,itemContent){
  22. itemHTML='<div id=item'+itemNo+' itemIndex='+itemNo+' style="position:relative;left:0;top:'+(-contentHeight*itemNo)+';width:'+layerWidth+';"><table width=100% cellspacing="0" cellpadding="0">'+
  23. '<tr><td height='+titleHeight+' onclick=changeItem('+itemNo+') class="titleStyle" align=center>'+itemTitle+'</td></tr>'+
  24. '<tr><td height='+contentHeight+' class="contentStyle">'+itemContent+'</td></tr></table></div>';
  25. document.write(itemHTML);
  26. itemNo++;
  27. }
  28. //添加菜单标题和内容,可任意多项,注意格式:
  29. addItem('贝买网','
  30.   欢迎光临贝买网!');
  31. addItem('测试','<center><a href="#">测试</a>

  32. <a href=".#">测试</a>

  33. <a href="#">返回首页</a></center>');
  34. addItem('测试','<center><a href=".#">测试</a>

  35. <a href=".#">测试</a>

  36. <a href=".#">测试</a>

  37. <a href=".#">测试</a>

  38. <a href="#">返回首页</a></center>');


  39. document.write('</span>')
  40. document.all.itemsLayer.style.height=itemNo*titleHeight+contentHeight;

  41. toItemIndex=itemNo-1;onItemIndex=itemNo-1;

  42. function changeItem(clickItemIndex){
  43. toItemIndex=clickItemIndex;
  44. if(toItemIndex-onItemIndex>0) moveUp(); else moveDown();
  45. runtimes++;
  46. if(runtimes>=stepNo){
  47. onItemIndex=toItemIndex;
  48. runtimes=0;}
  49. else
  50. setTimeout("changeItem(toItemIndex)",10);
  51. }

  52. function moveUp(){
  53. for(i=onItemIndex+1;i<=toItemIndex;i++)
  54. eval('document.all.item'+i+'.style.top=parseInt(document.all.item'+i+'.style.top)-contentHeight/stepNo;');
  55. }

  56. function moveDown(){
  57. for(i=onItemIndex;i>toItemIndex;i--)
  58. eval('document.all.item'+i+'.style.top=parseInt(document.all.item'+i+'.style.top)+contentHeight/stepNo;');
  59. }
  60. changeItem(0);
  61. //-->
  62. </script>
复制代码
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注-册

本版积分规则

Archiver|手机版|小黑屋|DoDVip ( 桂ICP备14000730号 )

GMT+8, 2025-5-1 18:26 , Processed in 0.063798 second(s), 21 queries .

Powered by Discuz! X3.5

Copyright © 2001-2024 Tencent Cloud.

快速回复 返回顶部 返回列表