您当前的位置:首页 > 帝国CMS教程

一款好用的css选项卡

来源:帝国CMS教程发布者:帝国CMS模板网时间:2010-03-18

<!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>
<script>
<!--
function setTab(name,cursel,n){
for(i=1;i<=n;i++){
var menu=document.getElementById(name+i);/* two1 */
var con=document.getElementById("con_"+name+"_"+i);/* con_two_1 */
menu.className=i==cursel?"hover":"";/*三目运算  等号优先*/
con.style.display=i==cursel?"block":"none";
}
}
//-->
</script>

<style type="text/css">

.city_ser_show{display:none;width:490px;height:200px;border:1px solid #CCCCCC;}
#con_two_1{display:block;}
#menubox{width:500px;height:24px;margin-bottom:7px;}
#menubox ul{margin:0;padding:0;}
#menubox ul li{float:left;list-style:none;display:inline;padding-top:7px;border:1px solid #D1D1D1;border-bottom:0px;margin:0 10px;white-space:nowrap; text-overflow:ellipsis;cursor:pointer;width:60px;height:24px;text-align:center;font-size:14px;overflow:visible;}
#menubox ul li.hover{border-top:2px solid #D1D1D1;border-right:2px solid #D1D1D1;border-left:2px solid #D1D1D1;color: #000000;font-weight:bold;border-bottom:0px solid #D1D1D1;}

</style>

</head>

<body>
<div id="main">
<div id="menubox">
<!--样式1  滑动选项卡-->
<!--
<ul>
<li id="two1" onmousemove="setTab('two',1,6)" class="hover">选项卡1</li>
<li id="two2" onmousemove="setTab('two',2,6)">选项卡2</li>
<li id="two3" onmousemove="setTab('two',3,6)">选项卡3</li>
<li id="two4" onmousemove="setTab('two',4,6)">选项卡4</li>
<li id="two5" onmousemove="setTab('two',5,6)">选项卡5</li>
<li id="two6" onmousemove="setTab('two',6,6)">选项卡6</li>
</ul>
-->
<!--样式2 -->
<ul>
<li id="two1" onclick="setTab('two',1,9)" class="hover"><a>选项卡1</a></li>
<li id="two2" onclick="setTab('two',2,9)"><a>选项卡2</a></li>
<li id="two3" onclick="setTab('two',3,9)"><a>选项卡3</a></li>
<li id="two4" onclick="setTab('two',4,9)"><a>选项卡4</a></li>
<li id="two5" onclick="setTab('two',5,9)"><a>选项卡5</a></li>
<li id="two6" onclick="setTab('two',6,9)"><a>选项卡6</a></li>
<li id="two7" onclick="setTab('two',7,9)"><a>选项卡7</a></li>
<li id="two8" onclick="setTab('two',8,9)"><a>选项卡8</a></li>
<li id="two9" onclick="setTab('two',9,9)"><a>选项卡9</a></li>

</ul>

</div>
<div id="conten">
<div class="city_ser_show" id="con_two_1">
选项卡1
<p>这个选项卡很NB吧!</p>
</div>
<div class="city_ser_show" id="con_two_2">
选项卡2
<p>是用javascript做的!</p>
</div>
<div class="city_ser_show" id="con_two_3">
选项卡3
<p>很无聊啊!</p>
</div>
<div class="city_ser_show" id="con_two_4">
选项卡4
<p>我很利害吧!</p>
</div>
<div class="city_ser_show" id="con_two_5">
选项卡5
<p>不要问我为什么!</p>
</div>
<div class="city_ser_show" id="con_two_6">
选项卡6
<p>都是为了大家的方便!</p>
</div>
<div class="city_ser_show" id="con_two_7">
选项卡6
<p>都是为了大家的方便!</p>
</div>
<div class="city_ser_show" id="con_two_8">
选项卡6
<p>都是为了大家的方便!</p>
</div>
<div class="city_ser_show" id="con_two_9">
选项卡6
<p>都是为了大家的方便!</p>
</div>
</div>
</div>
</body>
</html>

我自己写的 美工还得你自己来改