六狼论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

新浪微博账号登陆

只需一步,快速开始

搜索
查看: 18|回复: 0

css滑动门 (很简单好用)

[复制链接]

升级  47%

105

主题

105

主题

105

主题

举人

Rank: 3Rank: 3

积分
341
 楼主| 发表于 2013-2-7 16:43:32 | 显示全部楼层 |阅读模式

如果是感应触发.就选onmouseover
如果是点击触发.就选onclick [把它们两互相替换,就可随时变为感应或点击了]

而如果想在一个页面上有N个滑动门
就复制一套...将myTab0改成myTab1   myTab2   myTab3 等等等..都可以..或者换成你自己喜欢的名字...当然myTab0_Content0这个亦是要随着变动!
-----------------------------------------------------------------------------------------------------------------------------------
html部
-----------------------------------------------------------------------------------------------------------------------------------

<div class="nTab">
   <!-- TOP -->
   <div class="TabTitle">
          <ul id="myTab1">
            <li class="active" >星期一</li>
            <li class="normal" >星期二</li>
            <li class="normal" >星期三</li>
            <li class="normal" >星期四</li>
            <li class="normal" >星期五</li>
            <li class="normal" >星期六</li>
          </ul>
   </div>
   <!-- TOP 完-->
   <!-- 内容-->
   <div class="TabContent">
      <div id="myTab1_Content0">1</div>
      <div id="myTab1_Content1" class="none">2</div>
      <div id="myTab1_Content2" class="none">3</div>
      <div id="myTab1_Content3" class="none">4</div>
      <div id="myTab1_Content4" class="none">5</div>
      <div id="myTab1_Content5" class="none">6</div>
   </div>
   <!-- 内容 完-->
</div>
-----------------------------------------------------------------------------------------------------------------------------------
css部

-----------------------------------------------------------------------------------------------------------------------------------
.nTab{
float: left; font-weight: normal;
width: 300px; height:28px;
margin: 0 auto;
background-position:left;
background-repeat:repeat-y;
}
.nTab .TabTitle{
clear: both; border:0;
height: 28px;
overflow: hidden;
}
.nTab .TabTitle ul{

border:0;
margin:0;
padding:0;
}
.nTab .TabTitle li{

float: left;
width: 52px;
height:28px;
cursor: pointer;
margin-right:0px;
padding-right: 0px;
padding-left: 0px;
list-style-type: none;
}
.nTab .TabTitle .active{
line-height:28px; color:#FF3300; font-size:14px; text-align:center;}
.nTab .TabTitle .normal{
line-height:28px; font-size:12px; color:#712600; text-align:center; }
.nTab .TabContent{
height:40px;border:1px #333333 solid; font-weight: normal;}

.none {
display:none
;}
-----------------------------------------------------------------------------------------------------------------------------------
js部 加在<head></head>
-----------------------------------------------------------------------------------------------------------------------------------

<script type="text/javascript">
function nTabs(thisObj,Num){
if(thisObj.className == "active")return;
var tabObj = thisObj.parentNode.id;
var tabList = document.getElementById(tabObj).getElementsByTagName("li");
for(i=0; i <tabList.length; i++)
{
if (i == Num)
{
thisObj.className = "active";
document.getElementById(tabObj+"_Content"+i).style.display = "block";
}else{
tabList.className = "normal";
document.getElementById(tabObj+"_Content"+i).style.display = "none";
}
}
}

</script>

========================================以下是完整代码============
<!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" />
<title>无标题文档</title>
<style type="text/css">
<!--
.nTab{
float: left; font-weight: normal;
width: 300px; height:28px;
margin: 0 auto;
background-position:left;
background-repeat:repeat-y;
}
.nTab .TabTitle{
clear: both;
border:0;
height: 28px;
overflow: hidden;
background-color: #FFCCFF;
}
.nTab .TabTitle ul{
border:0;
margin:0;
padding:0;
}
.nTab .TabTitle li{
float: left;
width: 52px;
height:28px;
cursor: pointer;
margin-right:0px;
padding-right: 0px;
padding-left: 0px;
list-style-type: none;
}
.nTab .TabTitle .active{
line-height:28px;
color:#FFFFFF;
font-size:14px;
text-align:center;
background-color: #000000;
}
.nTab .TabTitle .normal{line-height:28px; font-size:12px; color:#712600; text-align:center; }
.nTab .TabContent{ height:40px;border:1px #333333 solid; font-weight: normal;}

.none {display:none;}

-->
</style>
<script type="text/javascript">
function nTabs(thisObj,Num){
if(thisObj.className == "active")return;
var tabObj = thisObj.parentNode.id;
var tabList = document.getElementById(tabObj).getElementsByTagName("li");
for(i=0; i <tabList.length; i++)
{
if (i == Num)
{
thisObj.className = "active";
document.getElementById(tabObj+"_Content"+i).style.display = "block";
}else{
tabList.className = "normal";
document.getElementById(tabObj+"_Content"+i).style.display = "none";
}
}
}
</script>

</head>
<body><div class="nTab">
   <!-- TOP -->
   <div class="TabTitle">
          <ul id="myTab1">
            <li class="active" >星期一</li>
            <li class="normal" >星期二</li>
            <li class="normal" >星期三</li>
            <li class="normal" >星期四</li>
            <li class="normal" >星期五</li>
            <li class="normal" >星期六</li>
          </ul>
   </div>
   <!-- TOP 完-->
   <!-- 内容-->
   <div class="TabContent">
      <div id="myTab1_Content0">1</div>
      <div id="myTab1_Content1" class="none">2</div>
      <div id="myTab1_Content2" class="none">3</div>
      <div id="myTab1_Content3" class="none">4</div>
      <div id="myTab1_Content4" class="none">5</div>
      <div id="myTab1_Content5" class="none">6</div>
   </div>
   <!-- 内容 完-->
</div>


</body>
</html>
您需要登录后才可以回帖 登录 | 立即注册 新浪微博账号登陆

本版积分规则

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