zoukankan      html  css  js  c++  java
  • 选项卡

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
        <style>
            body{
                background-color: #000000;
            }
            #box{
                width: 400px;
                height: 400px;
            }
            #box div{
                width: 300px;
                height: 200px;
                display: none;
                background-color: #ffffff;
                padding: 0.5em;
            }
            #box div img{
                max-width: 300px;
                max-height: 200px;
            }
            input{
    
                border: none;
                padding: 0.5em 1em;
                cursor: pointer;
                background-color: #767676;
                text-align: center;
                color: #ffffff;
                border-radius: 5px 5px 0 0;
            }
            .on{
                color: #000;
                background-color: #fff;
            }
        </style>
    </head>
    <body>
    <div id="box">
        <input type="button" value="切换1">
        <input type="button" value="切换2">
        <input type="button" value="切换3">
        <div style="display: block;">
            <img src="../img/1.png">
        </div>
        <div><img src="../img/2.png"></div>
        <div><img src="../img/3.png"></div>
    </div>
    <script>
        var oInput = document.getElementsByTagName("input");
        var oBox = document.getElementById("box");
        var oDiv = oBox.getElementsByTagName("div");
    
        function change(curIndex) {
            for(var i=0;i<oInput.length;i++){
                oInput[i].className = " ";
                oDiv[i].style.display = "none";
            }
            oInput[curIndex].className = "on";
            oDiv[curIndex].style.display = "block";
        }
    
        var index=0;
        var timer = null;
    
        timer = setInterval(play,1000);
    
        function play() {
            index++;
            if (index == oInput.length) {
                index = 0;
            }
            change(index);
        }
    
    
        play();
        for(var i=0;i<oInput.length;i++){
            oInput[i].onmouseover = function () {
                clearInterval(timer)
            };
            oInput[i].onmouseout = function () {
                timer = setInterval(play,1000);
            }
    
        }
    </script>
    </body>
    </html>

  • 相关阅读:
    用户交互
    python简介
    maven阿里云镜像setting
    apache虚拟主机的ip用法 包括iis
    apache的虚拟主机配置和指定目录的访问描述(
    apache重定向301 配置,根域名转到www
    前端学习
    一步一步写jQuery插件
    json 和 table控件
    下载相关
  • 原文地址:https://www.cnblogs.com/QianBoy/p/8194283.html
Copyright © 2011-2022 走看看