js实现向左轮换答题效果代码

代码语言:html

所属分类:其他

代码描述:js实现向左轮换答题效果代码

代码标签: 轮换 答题 效果

下面为部分代码预览,完整代码请点击下载或在bfwstudio webide中打开

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <style>

        .entrance-bottom {
            width: 100%;
            margin-top: 40px;
            overflow: hidden;
            margin-bottom: 50px;
            position: relative;
            height: 700px;
        }
        .entrance-bottom-frame {
            transition: all 0.8s;
            width: 10000%;
            margin: 0 auto;
            height: 630px;
            margin-top: 40px;
            position: absolute;
            left: 50%;
            margin-left: -550px;
        }
        .entrance-bottom-frame-beijing {
            position: absolute;
            z-index: 1;
            width: 100%;
            height: 100%;
            top: 0;
            left: 0;
            background: url(//repo.bfw.wiki/bfwrepo/image/60fe3c9d05beb.png);
            background-size: cover;
        }
        .entrance-bottom-frame-line {
            -webkit-filter: grayscale(100%);
            /* CSS3 filter方式,webkit内核方式,firefox外的绝大部分的现代浏览器*/
            -moz-filter: grayscale(100%);
            /* 目前没有实现 */
            -ms-filter: grayscale(100%);
            -o-filter: grayscale(100%);
            filter: grayscale(100%);
            /* CSS3 filter方式,标准写法*/
            filter: gray;
            /* IE 6-9 */
            transition: all 0.8s;
            pointer-events: none;
            cursor: default;
            margin-top: 35px;
            box-shadow: 0 0 15px #c5e2ff;
            width: 1000px;
            height: 570px;
            float: left;
            margin-left: 50px;
            position: relative;
        }
        .entrance-bottom-frame-line-id {
            font-size: 30px;
            color: white;
            text-align: center;
            line-height: 60px;
            position: absolute;
            left: 50%;
            margin-left: -30px;
            height: 60px;
            width: 60px;
            background: url(//repo.bfw.wiki/bfwrepo/image/60fe3c66e9401.png);
            background-size: cover;
            top: -30px;
        }
        .entrance-bottom-frame-line-title {
            font-size: 14px;
            width: 900px;
            margin: 70px auto 20px auto;
        }
        .entrance-bottom-frame-line-button {
            transition: margin 0.8s;
            position: relative;
            cursor: pointer;
            width: 420px;
            height: 70px;
            margin: 10px 20px 0px 45px;
            float: left;
            box-sizing: border-box;
            background: #f2f2f2;
            border-radius: 36px;
            padding: 0 35px;
        }
        .entrance-bottom-frame-line-button-id {
            width: 30px;
            line-height: 70px;
            display: table-cell;
            font-size: 24px;
        }
        .entrance-bottom-frame-line-button-frame {
            line-height: 20px;
            width: 335px;
            height: 70px;
            display: table-cell;
            vertical-align: middle;
        }
        .entrance-bottom-frame-line-button:hover {
            color: white;
            background: -webkit-linear-gradient(left,#ff916a, #ff6a6b);
            /* Safari 5.1 - 6.0 */
            background: -o-linear-gradient(right,#ff916a, #ff6a6b);
            /* Opera 11.1 - 12.0 */
            background: -moz-linear-gradient(right,#ff916a, #ff6a6b);
            /* Firefox 3.6 - 15 */
            background: linear-gradient(toright,#ff916a, #ff6a6b);
            /* 标准的语法 */
        }
        .entrance-bottom-frame-line.active {
            pointer-events: auto;
            height: 630px;
            margin-top: 0;
            -webkit-filter: grayscale(0%);
            /* CSS3 filter方式,webkit内核方式,firefox外的绝大部分的现代浏览器*/
            -moz-filter: grayscale(0%);
            /* 目前没有实现 */
            -ms-filter: grayscale(0%);
            -o-filter: grayscale(0%);
            filter: grayscale(0%);
            /* CSS3 filter方式,标准写法*/
            filter: none;
        }
        .entrance-bottom-frame-line.active .entrance-bottom-frame-line-button {
            margin-top: 30px;
        }
        .entrance-bottom-frame-line.active .entrance-bottom-frame-beijing {
            display: none;
        }
        .entrance-bottom-frame-beijing.none {
            background: #000000;
            opacity: 0.2;
        }
        .pre_message {
            width: 900px;
            height: 280px;
            overflow-y: auto;
            overflow-x: hidden;
            padding: 35px 90px;

            box-sizing: border-box;
            outline: none;
            border: 0;
            white-space: pre-wrap;
            word-break: normal;
            background: url(//repo.bfw.wiki/bfwrepo/image/60fe3c8448b3f.png);
            margin: 0 auto;
            font-size: 14px;
        }
        .pre_message::-webkit-scrollbar {
            display: none;
        }

    </style>
</head>
<body>
    <div class="index">
        <div class="entrance-bottom">
            <div class="entrance-bottom-frame clearfix">

            </div>
        </div>
    </div>
</body>
<script type="text/javascript">
    function TiMu() {
        for (var i in data1) {
            var div = document.createElement("div");
            div.className = "entrance-bottom-frame-line";
            document.querySelector(".entrance-bottom-frame").appendChild(div);

            var beijing = document.createElement("div");
            beijing.className = "entrance-bottom-frame-beijing";
            document.querySelectorAll(".entrance-bottom-frame-line")[i].appendChild(beijing);

            var div1 = document.createElement("div");
            div1.className = "entrance-bottom-frame-line-id";
            div1.innerHTML = data1[i].id;
            document.querySelectorAll(".entrance-bottom-frame-line")[i].appendChild(div1);

            var div2 = document.createElement("div");
            div2.className = "entrance-bottom-frame-line-title";
            div2.innerHTML = data1[i].title;
            document.querySelectorAll(".entrance-bottom-frame-line")[i].appendChild(div2);

            var code = document.createElement("code");
            var pre = document.createElement("pre");
            code.innerHTML = data1[i].code;
            pre.appendChild(code);
            pre.className = "pre_message"
            document.querySelectorAll(".entrance-bottom-frame-line")[i].appendChild(pre);

            for (var j in data1[i].xuanxiang) {
                var div3 = document.createElement("div");
                div3.className = "entrance-bottom-frame-line-button";
                var div3_id = document.createElement("div");
                div3_id.className = "entrance-bottom-frame-line-button-id";
                if (j == 0) {
                    div3_id.innerHTML = "A";
                } else if (j == 1) {
                    div3_id.innerHTML = "B";
                } else if (j == 2) {
                    div3_id.innerHTML = "C";
                } else {
                    div3_id.innerHTML = "D";
                }
                var div4 = document.createElement("div");
                div4.className = "entrance-bottom-frame-line-button-frame";
                div4.innerHTML = data1[i].xuanxiang[j];
                div3.appendChild(div3_id)
                div3.appendChild(div4);
                document.querySelectorAll(".entrance-bottom-frame-line")[i].appendChild(div3);
            }
        }

    }

    function addClass(obj, cls) {
        var obj_class = obj.className,
        //获取 class 内容.
        blank = (obj_class != '') ? ' ': ''; //判断获取到的 class 是否为空, 如果不为空在前面加个'空格'.
        added = obj_class + blank + cls; //组合原来的 class 和需要添加的 class.
        obj.className = added; //替换原来的 class.
    }

    function removeClass(obj, cls) {
        var obj_class = ' '+obj.className+' '; //获取 class 内容, 并在首尾各加一个空格. ex) 'abc    bcd' -> ' abc    bcd '
        obj_class = obj_class.replace(/(\s+)/gi, ' '),
        //将多余的空字符替换成一个空格. ex) ' abc    bcd ' -> ' abc bcd '
        removed = obj_class.replace(' '+cls+' ', ' '); //在原来的 class 替换掉首尾加了空格的 class. ex) ' abc bcd ' -> 'bcd '
        removed = removed.replace(/(^\s+)|(\s+$)/g, ''); //去掉首尾空格. ex) 'bcd ' -> 'bcd'
        obj.className = removed; //替换原来的 class.
    }

    function hasClass(obj, cls) {
        var obj_class = obj.className,
        //获取 class 内容.
        obj_class_lst = obj_class.split(/\s+/); //通过split空字符将cls转换成数组.
        x = 0;
        for (x in obj_class_lst) {
            if (obj_class_lst[x] == cls) {
                //循环数组, 判断是否包含cls
                return true;
            }
        }
        return false;
    }


    function getStyle(obj, attr) {
        if (obj.currentStyle) {
            return obj.currentStyle[attr];
        } else {
            return document.defaultView.getComputedStyle(obj, null)[attr];
        }
    }

    //计时用
    //function CountDown() {
    //        minutes = Math.floor(mintime / 60);
    //       seconds = Math.floor(mintime % 60);
    //       if(minutes < 10){
    //       	minutes1 = "0" + minutes
    //       }else{
    //       	minutes1 = minutes
    //       }
    //       if(seconds < 10){
    //       	seconds1 = "0" + seconds
    //       }else{
    //       	seconds1 = seconds
    //       }
    //       msg =   minutes1 + ":" + seconds1;
    //       document.all["timer"].innerHTML = msg;
    ////       if (maxtime == 5 * 60)alert("还剩5分钟");
    //           ++mi.........完整代码请登录后点击上方下载按钮下载查看

网友评论0