zoukankan      html  css  js  c++  java
  • 无限循环跑马灯

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <title>Document</title>
        <style>
            .box {
                margin: 0 auto;
                 1000px;
                border: 1px solid red;
                overflow:hidden;
                padding-left: 20px;
                position: relative;
                height: 50px;
            }
            .text {
                white-space:nowrap;
                position: absolute;
                left: 200px;
            }
            .pwd {
                white-space:nowrap;
                position: absolute;
                left: 1020px;
            }
        </style>
    </head>
    <body>
        
        <div class="box">
            <span class="text">
                文字表达力是一个人的显性综合能力,也是外在的现实竞争力。在现代社会,每个人从事的职业或许不同,但自身的能力和水平都程度不同地需要用文字表达出来。
            </span>
            <span class="pwd">
                文字表达力是一个人的显性综合能力,也是外在的现实竞争力。在现代社会,每个人从事的职业或许不同,但自身的能力和水平都程度不同地需要用文字表达出来。
            </span>
        </div>

        <script>
            var box = document.getElementsByClassName('box')[0];
            var text = document.getElementsByClassName('text')[0];
            var pwd = document.getElementsByClassName('pwd')[0];
            var boxWidth = document.getElementsByClassName('box')[0].offsetWidth;
            var textWidth = document.getElementsByClassName('text')[0].offsetWidth;
            var pwdWidth = document.getElementsByClassName('pwd')[0].offsetWidth;
             window.onload=function checkScrollLeft(){
                if(boxWidth >= textWidth){ return false}
                toScrollLeft()
            }
            function toScrollLeft(){
                let a = text.offsetLeft + textWidth;
                if(a > 0){
                    text.style.left = text.offsetLeft - 1 + 'px';
                    setTimeout('toScrollLeft()', 18);
                }
                else{
                    text.style.left = 1020+ "px";
                    toScrollLeftPwd();
                }
            }
            function toScrollLeftPwd(){
                let a = pwd.offsetLeft + pwdWidth;
                if(a > 0){
                    pwd.style.left = pwd.offsetLeft - 1 + 'px';
                    setTimeout('toScrollLeftPwd()', 18);
                }
                else{
                    pwd.style.left = 1020 + "px";
                    toScrollLeft();
                }
            }
        </script>

    </body>
    </html>

    Talk is cheap,show me the code
  • 相关阅读:
    链接
    列表
    Android Studio AVD 虚拟机 联网 失败
    docker error during connect: Get http://%2F%2F.%2Fpipe%2Fdocker_engine/v1.29/containers/json: open //./pipe/docker_engine: The system cannot find the file specified. In the default daemon configuratio
    JSP Failed to load resource: net::ERR_INCOMPLETE_CHUNKED_ENCODING
    js jsp form
    intellij jsp 中文乱码
    [转载]在Intellij Idea中使用JSTL标签库
    windows pybloomfilter
    docker mysql
  • 原文地址:https://www.cnblogs.com/qc-one/p/13732954.html
Copyright © 2011-2022 走看看