• 小图在上选项卡


    <!DOCTYPE html>
    <html>
        <head>
            <meta charset="utf-8">
            <title>选项卡</title>
            <style type="text/css">
                *{margin: 0; padding: 0; font-family: "微软雅黑";font-size: 14px;}
                #container{
                     398px;
                    margin: 100px auto;}
                #container a{
                    display:block ;
                     98px;
                    height: 42px;
                    line-height: 42px;
                    text-align: center;
                    float: left;
                    border-top: solid 1px #FF4400;
                    border-bottom: solid 1px #FF4400;
                    border-left: solid 1px #FF4400;
                    color: #333333;
                    text-decoration: none;
                }
                #container a:hover{
                    color: #FF4400;
                }
                .content{
                     355px;
                    height: 140px;
                    text-align: center;
                    border-right: solid 1px #FF4400;
                    border-bottom: solid 1px #FF4400;
                    border-left: solid 1px #FF4400;
                    padding: 30px 0 0 40px;
                    display: none;
                }
                .clear{clear: left;}
                #container a.on{ background: #FF4400; color: #fff;}
            </style>
        
        </head>
        <body>
            <div id="container">
                <a href="#" class="on">充话费</a>
                <a href="#">充流量</a>
                <a href="#">充固话</a>
                <a href="#" style="border-right: solid 1px #FF4400;">充宽带</a>

                <div class="clear"></div>
                
                <div class="content" style="display:block;">
                    <img src="images/1.png" />
                </div>
                <div class="content">
                    <img src="images/2.png" />
                </div>
                <div class="content">
                    <img src="images/3.png" />
                </div>
                <div class="content">
                    <img src="images/4.png" />
                </div>


            </div>
        </body>
    </html>
    <script type="text/javascript">
        //页面结构分析 : 保证标题的下标和内容的下标一一对应
        
        var bts = document.getElementsByTagName("a");
        // 为四个标题对应添加属性 用来存储每一个标题在页面中的下标
        /*bts[0].index = 0;
        bts[1].index = 1;
        bts[2].index = 2;
        bts[3].index = 3;*/
        
        /*for( var i = 0 ; i < bts.length ; i++ ){
            bts[i].index = i;
        }*/
        
        var cons = document.getElementsByClassName("content");
        //第一步 : 为四个标题添加相同的事件
        for( var i = 0 ; i < bts.length ; i++ ){
            bts[i].index = i;//为四个标题对应添加属性 用来存储每一个标题在页面中的下标
            bts[i].onmouseover = function(){
                //第三步 : 排他思想
                //先通过循环清空所有的标题样式 隐藏所有的内容
                for( var j = 0 ; j <bts.length ; j++ ){
                    bts[j].className = "";
                    cons[j].style.display = "none";
                }           
                //第二步 : 为当前操作的标题添加类 on
                this.className = "on";
                
                //第四步 :根据当前操作的标题显示对应的内容
                // 通过当前操作标题的下标 查找 对应的内容
                cons[ this.index ].style.display = "block";
            }
        }
    </script>
  • 相关阅读:
    JedisConnectionException: java.net.ConnectException: Connection refused
    Mysql索引整理总结
    jstat命令总结
    Java死锁排查和Java CPU 100% 排查的步骤整理
    Spring-Session实现Session共享实现原理以及源码解析
    Spring-Session实现Session共享Redis集群方式配置教程
    Spring-Session实现Session共享入门教程
    Redis高可用集群-哨兵模式(Redis-Sentinel)搭建配置教程【Windows环境】
    jsp获取当前日期,包括星期几
    使用joda-time工具类 计算时间相差多少 天,小时,分钟,秒
  • 原文地址:https://www.cnblogs.com/tis100204/p/10328886.html
Copyright © 2020-2023  润新知