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>

  • 相关阅读:
    turtle 绘制爱心
    数据库总结
    anconda安装使用
    爬虫之存储库MongoDB
    【python】代码换行的几种方法
    【python】 合并列表的方法
    【notebook】常用在线notebook总结
    【PDF】PDF无法注释的一种解决方案
    【课程】MIT深度学习课程:架起理论与实践的桥梁
    【今日CV 视觉论文速览】Thu, 21 Feb 2019
  • 原文地址:https://www.cnblogs.com/QianBoy/p/8194283.html
Copyright © 2011-2022 走看看