码迷,mamicode.com
首页 > 其他好文 > 详细

选项卡

时间:2017-03-25 00:49:14      阅读:186      评论:0      收藏:0      [点我收藏+]

标签:logs   border   tag   splay   bsp   otto   relative   order   pad   

<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title></title>
    <style type="text/css">
         *{
             margin: 0;
             padding: 0;
             font-size: 32px;
         }
        ul,li{
            list-style: none;
        }
        #tab{
            margin: 10px auto ;
            width: 500px;
        }
        #tab ul{
            position: relative;
            top: 1px;
            z-index: 100;
        }
        #tab ul li{
            float: left;
            margin-right: 5px;
            margin-left: 5px;
            width: 100px;
            height: 30px;
            width: 30%;
            line-height: 30px;
            text-align: center;
            border: 1px solid #dddddd;
            cursor: pointer;
        }
         #tab ul li.select{
             border-bottom: none;
             background:red;
         }
        #tab div{
            display: none;
            clear: both;
            height: 100px;
            line-height: 100px;
            text-align: center;
            border:1px solid #dddddd;
        }
        #tab div.select{
            display: block;
        }
    </style>
</head>
<body>
         <div id="tab">
             <ul>
                 <li class="select">视频</li>
                 <li>综艺</li>
                 <li>秒拍</li>
             </ul>
             <div class="select">视频内容</div>
             <div>综艺内容</div>
             <div>秒拍内容</div>

         </div>
         <script type="text/javascript">
             var oTab =document.getElementById("tab");
             var oLis = oTab.getElementsByTagName("li");
             var oDivs = oTab.getElementsByTagName("div");

             for(var i = 0;i<oLis.length;i++){

                 var oLi =oLis[i];
                 oLi.index = i;
                 oLi.onmouseover = function(){
                     for(var j = 0;j<oLis.length;j++){

                         oLis[j].className="";
                         oDivs[j].className="";
                     }
                     this.className="select";
                     oDivs[this.index].className="select";
                 }
                 oLi.onmouseout = function(){
                     for(var j = 0;j<oLis.length;j++){
                         console.log("进来了111   "+i);
                         oLis[j].className="";
                         oDivs[j].className="";
                     }
                     oLis[0].className="select";
                     oDivs[0].className="select";
                 }
             }
         </script>
</body>
</html>

 

选项卡

标签:logs   border   tag   splay   bsp   otto   relative   order   pad   

原文地址:http://www.cnblogs.com/zzzzzzzsy/p/6614044.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!