当前位置:Gxlcms > JavaScript > js抛物线简单讲解

js抛物线简单讲解

时间:2021-07-01 10:21:17 帮助过:3人阅读

本文主要和大家分享js抛物线简单讲解,希望能帮助到大家。

<!DOCTYPE html><html lang="en"><head>
    <meta charset="UTF-8">
    <title>Document</title>
    <style>
        * {            margin: 0;            padding: 0;        }

        .box {            width: 0px;            height: 0px;            margin-left: 500px;            margin-top: 500px;            position: relative;        }

        .dian {            position: absolute;            width: 4px;            height: 4px;            margin-left: -2px;            margin-top: -2px;            border-radius: 50%;            background-color: red;        }

        .row {            position: absolute;            left: 50%;            margin-left: -250px;            width: 500px;            height: 1px;            background-color: green;        }

        .col {            position: absolute;            top: 50%;            margin-top: -250px;            width: 1px;            height: 500px;            background-color: green;        }
    </style></head><body>
    <p class="box">
        <p class="row"></p>
        <p class="col"></p>
        <p class="dian"></p>
    </p>
    <script>  
        var x = -100
        setInterval(function () {
            x = x + 2;            var y = -x * x / 100 + x / 100 + 30;            var dian = document.querySelector('.dian');
            dian.style.left = x + 'px';
            dian.style.top = -y + 'px';
        }, 10)    </script></body></html>

相关推荐:

JS抛物线动画操作实例分享

以上就是js抛物线简单讲解的详细内容,更多请关注Gxl网其它相关文章!

人气教程排行