css+div+js 選項卡效果 簡潔

來源:互聯網
上載者:User

<!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">
<!--
#grant {
font-family: Arial, Helvetica, sans-serif;
font-size: 13px;
color: #3366CC;
text-decoration: none;
height: 300px;
width: 400px;
margin:0 auto;
border:1px solid #3366CC;
}
#menu {
height: 30px;
filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#cecfde, EndColorStr=#ffffff);

}
#menu ul{
margin:0;
padding:0;}

#menu li{
width:98px;
float:left;
display:block;
list-style-type:none;
text-align:center;
height:28px;
line-height:28px;
border:1px solid #ddd;
}
#menu li.hover{
border:1px solid #bbb;
border-bottom:0px;
font-weight:bold;
filter: progid:DXImageTransform.Microsoft.Gradient(GradientType=0, StartColorStr=#8296C7, EndColorStr=#ffffff);
}
#cont{
margin:5px;}
-->
</style>
<script>
<!--
function setTab(name,cursel,n)
{
for(i=1;i<=n;i++)
{
var menu=document.getElementById(name+i);
var con=document.getElementById("cont"+i);
menu.className=i==cursel?"hover":"";
con.style.display=i==cursel?"block":"none";
}
}
//-->
</script>
</head>

<body>

<div id="grant">
<div id="menu">
      <ul>
          <li id="menu1" class="hover" onmouseover="setTab('menu',1,4)">國內</li>
          <li id="menu2" onmouseover="setTab('menu',2,4)">國際</li>
          <li id="menu3" onmouseover="setTab('menu',3,4)">體育</li>
          <li id="menu4" onmouseover="setTab('menu',4,4)">娛樂</li>
      </ul>
</div>
<div id="cont">
    <div id="cont1" class="hover">國內國內國內國內國內國內國內國內國內國內國內國內國內</div>
    <div id="cont2" style="display:none">國際國際國際國際國際國際國際國際國際國際國際國際國際</div>
    <div id="cont3" style="display:none">體育體育體育體育體育體育體育體育體育體育體育體育體育</div>
    <div id="cont4" style="display:none">娛樂娛樂娛樂娛樂娛樂娛樂娛樂娛樂娛樂娛樂娛樂娛樂娛樂</div>
</div>
</div>
</body>
</html>

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.