当前位置:编程学习 > JS >>

透明度慢慢变化的竖向JS+css菜单

一个CSS结合JavaScript共同完成的垂直菜单,鼠标放上去对应的菜单项的透明度会慢慢发生变化,字体的颜色也会慢慢改变,整体效果不错,请运行一下看效果。
答案:<title>半透明菜单</title>
<style>
. tds {
  background-Color:silver;
  width:100;
  height:20;
  text-align:center;
  border:1px solid gray;
  font-size:12PX;
  filter:alpha(opacity=45);
  -moz-opacity:45%;
  cursor:crosshair;
 }
</style>
<SCRIPT LANGUAGE="JavaScript">
<!-- Begin
function locktrueie(myform){myform.ie.checked=true;}
function lockfalsenet(myform){myform.nets.checked=true;}
function goToURL() { window.location = "/"; }
function nochange(mycheckbox)
{
   if (mycheckbox.checked == true){mycheckbox.checked = false;}else{mycheckbox.checked = true;}
}

//  End -->
</script>
<script language="javascript">
nOpac = 50
nPlus = 2
nMin = 1
speed = 30
timer = null; 
timer2 = null;
var ie5=(document.all  &&  document.getElementById);
var ns6=(!document.all  &&  document.getElementById);
function fadeImg2(teller)
{
 apl[teller][1] = "Up";
 changes();
}

function fadeImgend2(teller)
{
 apl[teller][1] = "Down";
 setTimeout("changes()",50);
}
function changes()
{
 next_loop = true;
 for (i=0;i<apl.length;i++)
 {
  obj = link_table.rows[i].cells[0];
  opacity = apl[i][0]
  if (apl[i][1] == "Up")
  {
     opacity += nPlus;
     apl[i][0] = opacity;
     if (apl[i][0] > 105) 
      {apl[i][1] = "";}
     else
     {next_loop = false;}
	 nOpac = opacity;
  }
  else
  {
  if (apl[i][1] == "Down")
  {
     opacity -= nMin;
     apl[i][0] = opacity;
     if (apl[i][0] < 45) 
      {apl[i][1] = "";}
     else
     {next_loop = false;}
	 nOpac = opacity;
  }
  }
  if(ie5){ 
	obj.style.filter="alpha(opacity="+opacity+")";
    }
  if(ns6){ 
   	obj.style.MozOpacity = opacity + '%';
   }
 }
 if (next_loop == false)
  {
   timer = setTimeout("changes()",speed);
  }
  else
  {
   clearTimeout(timer);
  }
}

var apl = new Array();
apl[0] = new Array(45,"");
apl[1] = new Array(45,"");
apl[2] = new Array(45,"");
apl[3] = new Array(45,"");
apl[4] = new Array(45,"");
apl[5] = new Array(45,"");
//expl: apl[6] = new Array(45,"");
</script>
<table cellpadding=0 cellspacing=0 name=link_table id=link_table>
<tr>
<td class="tds" onmouseover="fadeImg2(0)" onmouseout="fadeImgend2(0)" onclick="window.location='/';" style="border:1px solid gray;background-color:silver;width:100;text-align:center">源码首页</td>
</tr>
<tr>
<td class="tds" onmouseover="fadeImg2(1)" onmouseout="fadeImgend2(1)" onclick="window.location='/';" style="border:1px solid gray;background-color:silver;width:100;text-align:center">论坛社区</td>
</tr>
<tr>
<td class="tds" onmouseover="fadeImg2(2)" onmouseout="fadeImgend2(2)" onclick="window.location='/';" style="border:1px solid gray;background-color:silver;width:100;text-align:center">博客导航</td>
</tr>
<tr>
<td class="tds" onmouseover="fadeImg2(3)" onmouseout="fadeImgend2(3)" onclick="window.location='/';" style="border:1px solid gray;background-color:silver;width:100;text-align:center">网页特效</td>
</tr>
<tr>
<td class="tds" onmouseover="fadeImg2(4)" onmouseout="fadeImgend2(4)" onclick="window.location='/';" style="border:1px solid gray;background-color:silver;width:100;text-align:center">最新更新</td>
</tr>
<tr>
<td class="tds" onmouseover="fadeImg2(5)" onmouseout="fadeImgend2(5)" onclick="window.location='/';" style="border:1px solid gray;background-color:silver;width:100;text-align:center">下载排行</td>
</tr>
</table>

上一个:带圆角的纯CSS下拉导航菜单
下一个:宽度可以伸缩的选项卡,来自网易

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,