js实现简洁的TAB滑动门效果代码

这是一款滑动门代码,简洁TAB,简单的鼠标导航效果,大家或许经常见到的效果啦,鼠标放在主菜单上,下边框架内的内容会跟着变换,鼠标不需要点击,只需要滑上去就可切换内容,像一扇门,所以有时候别人叫“滑动门”菜单。

运行效果如下图所示:

js实现简洁的TAB滑动门效果代码

在线演示地址如下:

具体代码如下:

<html> <head> <title>简洁TAB</title> <script type="text/javascript"> function nTabs(thisObj, Num) { if (thisObj.className == "active") return; var tabObj = thisObj.parentNode.id;//赋值指定节点的父节点的id名字 var tabList = document.getElementById(tabObj).getElementsByTagName("li"); for (i = 0; i < tabList.length; i++) {//点击之后,其他tab变成灰色,内容隐藏,只有点击的tab和内容有属性 if (i == Num) { thisObj.className = "active"; document.getElementById(tabObj + "_Content" + i).style.display = "block"; } else { tabList[i].className = "normal"; document.getElementById(tabObj + "_Content" + i).style.display = "none"; } } } </script> <style type="text/css"> * { margin: 0; padding: 0; list-style: none; font-size: 14px; } .nTab { width: 500px; height:200px; margin: 20px auto; border: 1px solid #333; overflow: hidden; } .none { display: none; } .nTab .TabTitle li { float: left; cursor: pointer; height: 35px; line-height: 35px; font-weight: bold; text-align: center; width: 124px; } .nTab .TabTitle li a { text-decoration: none; } .nTab .TabTitle .active { background-color:blue; color: #336699; } .nTab .TabTitle .normal { color: #F1AC1C; } .nTab .TabContent { clear: both; overflow: hidden; background: #fff; padding: 5px; display: block; height:100px; } </style> </head> <body> <div> <div> <ul> <li>ASP</li> <li>PHP2</li> <li>PHP3</li> <li>PHP4</li> </ul> </div> <div > <div> 第一块内容</div> <div> 第二块内容</div> <div> 第三块内容</div> <div> 第四块内容</div> </div> </div> </body> </html>

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wggdyw.html