js+css制作超简洁选项卡切换特效

1个月前 (04-16 11:03)阅读34回复0
大陆
大陆
  • 管理员
  • 发消息
  • 注册排名1
  • 经验值4714
  • 级别管理员
  • 主题942
  • 回复2
楼主

分享一款js制作的简洁滑动门菜单特效,当用户的鼠标经过时切换显示,可根据自己的需求来自己美化。

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<meta name="keywords" content="武鸣人网站,武鸣信息网,武鸣本地网,武鸣信息资源平台,减肥,健身,励志,励志语录,js特效,网页特效,www.wuming.ren">
<meta name="description" content="欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。">
<title>js+css制作超简洁选项卡切换特效_武鸣人</title>
<style>
#tab_wuming_ren{width:310px;text-align:left;border:1px solid #cccccc;background:url() repeat-x top;}
.tab_nav_wuming{height:24px;overflow:hidden;font-size:12px;background:url() repeat-x bottom; padding-left:10px;}
.tab_nav_wuming ul{font-size:9pt;margin:0;padding:0;}
.tab_nav_wuming_li{background:url() no-repeat -70px 0;width:70px;height:24px;line-height:24px;float:left;display:inline;overflow:hidden;text-align:center;cursor:pointer;}
.tab_nav_wuming_li_first{font-weight:bolder;background-position:0px 0px;}
.tab_nav_wuming_li a{text-decoration:none;color:#000000;font-size:12px;}
.tab_body_wuming{border-top:none;min-height:175px;padding:10px;height:175px;}
.cls_div_wumingren{display:none;font-size:14px;}
.tab_nav_wuming_li_first a{color:#c80000;}
</style>
</head>
<body>
<a href="https://www.wuming.ren">武鸣人</a>,各种信息资源免费发布,分享励志语录经典短句,减肥健身常识,各种js特效代码。网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)<hr>
<!--欢迎来到武鸣人信息资源平台,各种信息免费发布,资源共享合作共赢,分享互联网流行的励志语录经典短句,减肥健身健康小常识及打卡记录,收集各种js特效代码。-->
<script type="text/javascript" src="https://www.wuming.ren/ad/tc.js"></script>
<script type="text/javascript" src="https://www.wuming.ren/ad/a.js"></script>
    <div id="tab_wuming_ren" >
 <div class="tab_nav_wuming">
  <ul>
   <li class="tab_nav_wuming_li tab_nav_wuming_li_first"><a href="https://www.wuming.ren">武鸣人一号</a></li>
   <li class="tab_nav_wuming_li"><a href="https://www.wuming.ren">武鸣人二号</a></li>
   <li class="tab_nav_wuming_li"><a href="https://www.wuming.ren">武鸣人三号</a></li>
  </ul>
 </div>
 <div class="tab_body_wuming">
  <div class="cls_div_wumingren" style="display:block;">一号选项卡内容,武鸣人网。<br /><a href="https://www.wuming.ren">武鸣人网</a>,各种信息免费发布,资源共享合作共赢!</div>
  <div class="cls_div_wumingren">二号选项卡内容,武鸣人网。<br /><a href="https://www.wuming.ren">武鸣人网</a>,各种信息免费发布,资源共享合作共赢!</div>
  <div class="cls_div_wumingren">三号选项卡内容,武鸣人网。<br /><a href="https://www.wuming.ren">武鸣人网</a>,各种信息免费发布,资源共享合作共赢!</div>
 </div>
</div>
<script type="text/javascript">
try{
 document.execCommand("BackgroundImageCache", false, true);
}catch(e){}
function $(element){
 if(arguments.length>1){
  for(var i=0,elements=[],length=arguments.length;i<length;i++)
   elements.push($(arguments[i]));
  return elements;
 }//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
 if(typeof element=="string")
  return document.getElementById(element);
 else
  return element;
}//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
var Class={
 create:function(){
  return function(){
   this.initialize.apply(this,arguments);
  } 
 }
}//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
Object.extend=function(destination,source){
 for(var property in source){
  destination[property]=source[property];
 }
 return destination;
}//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
var tabmenu_wuming=Class.create();
tabmenu_wuming.prototype={
 initialize:function(container,selfOpt,otherOpt){
  this.container=$(container);
    var selfOptions=Object.extend({fontWeight:"bold",fontSize:"12px",color:"#FFBC44"},selfOpt||{});
  var otherOptions=Object.extend({fontWeight:"normal",fontSize:"12px",color:"#666"},otherOpt||{});
  //用for循环得到objs数组,主要是为了兼容非IE浏览器把空白也当作子对象
  for(var i=0,length=this.container.childNodes.length,objs=[];i<length;i++){
   if(this.container.childNodes[i].nodeType==1)
    objs.push(this.container.childNodes[i]);
  }
  var tabArray=objs[0].getElementsByTagName("li");
  //用for循环得到divArray数组,主要是为了兼容非IE浏览器把空白也当作子对象
  var divArray=new Array();
  for(i=0,length=objs[1].childNodes.length;i<length;i++){
   if(objs[1].childNodes[i].nodeType==1)
    divArray.push(objs[1].childNodes[i]);
  }
//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
  for(i=0,length=tabArray.length;i<length;i++){
   tabArray[i].length=length;
   tabArray[i].index=i;
   tabArray[i].onmouseover=function(){
    //其它选项卡样式设置
    for(var j=0;j<this.length;j++){
     tabArray[j].style.backgroundPosition="-"+tabArray[j].offsetWidth+"px 0";
     for(var property in selfOptions){
      tabArray[j].firstChild.style[property]=otherOptions[property];
     }
    }
    //当前选项卡样式
    this.style.backgroundPosition="0 0";
    for(var property in selfOptions){
     this.firstChild.style[property]=selfOptions[property];
    }
    //隐藏其它选项卡
    for(j=0;j<this.length;j++){
     divArray[j].style.display="none";
    }
    //显示当前选项卡
    divArray[this.index].style["display"]="block";
   }
  }
 }
}//武鸣人网站https://www.wuming.ren 网站很好记住,wuming.ren(武鸣拼音.ren域名后缀)
var tab1=new tabmenu_wuming("tab_wuming_ren",{fontSize:"12px",color:"#c80000",fontWeight:"bolder"},{fontWeight:"normal",color:"#000000"});
</script>
</body>  
</html>


0
0
收藏0
回帖

js+css制作超简洁选项卡切换特效 期待您的回复!

取消
载入表情清单……
载入颜色清单……
插入网络图片

取消确定

图片上传中
编辑器信息
提示信息