Menu



Manage

파일 목록
Study_Web > 이후/챌린지 copy.html Lines 88 | 2.8 KB
다운로드

                        <!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>snow song show</title>
    <style>
        body {
            background-image: url("media/snow song show.png");
            background-repeat: no-repeat;
            background-color: #000;
        }

        div {
            border-style: none;
            font-size: small;
            color: white;
        }
        }
    </style>
    <script>
        var width = 1024;
        var height = 768;
        var snowcount = 30;

        function first_pos() {
            var text = "";
            for (i = 0; i < snowcount; i++) {
                ranlocation = Math.floor(Math.random() * (width - 1 + 1) + 1);
                rantoplocation = Math.floor(Math.random() * (height - 1 + 1) + 1);
                text = "<div style='position: absolute; top:" + rantoplocation + "px; left: " + ranlocation + "px; '>*</div>";
                document.body.innerHTML += text;
            }
        }
        function down_pos() {
            var arrdivs = document.getElementsByTagName("div");

            for (i = 0; i < arrdivs.length; i++) {
                var newoffsettop = arrdivs[i].offsetTop + 10;
                var offsetleft = arrdivs[i].offsetLeft;

                if (newoffsettop > 850) { /* 이미지 크기를 넘긴경우 */
                    start_pos(arrdivs[i]);
                }
                else {
                    var newdiv = document.createElement("div");

                    newdiv.setAttribute("style", "left: " + offsetleft + "px; top : " + newoffsettop + "px; position : absolute;");

                    newdiv.innerHTML = "ㆍ";
                    document.body.replaceChild(newdiv, arrdivs[i]);
                }
            }

        }

        function start_pos(arrdiv) {
            ranlocation = Math.floor(Math.random() * (width - 1 + 1) + 1);
            rantoplocation = Math.floor(Math.random() * (height - 700 - 1 + 1) + 1);

            var newdiv = document.createElement("div");
            newdiv.style.left = ranlocation;
            newdiv.style.top = rantoplocation;
            newdiv.style.position = "absolute";

            newdiv.setAttribute("style", "left: " + ranlocation + "px; top : " + rantoplocation + "px; position : absolute;");

            newdiv.innerHTML = "*";

            document.body.replaceChild(newdiv, arrdiv);

        }

        document.addEventListener("DOMContentLoaded", function () {
            first_pos();
            setInterval("down_pos()", Math.random() * 500
            );
        });

    </script>
</head>

<body>
</body>

</html>