您好,欢迎访问一九零五行业门户网

js实现打印一个彩色的菱形(代码)

本篇文章给大家带来的内容是关于js实现打印一个彩色的菱形(代码),有一定的参考价值,有需要的朋友可以参考一下,希望对你有所帮助。
<!doctype html><html><head>    <meta charset="utf-8">    <title>weirdo</title>    <style>        * {            margin: 0;            padding: 0;            box-sizing: border-box;        }        .lx {            text-align: center;            letter-spacing: 5px;            margin: 20px;        }    </style></head><body><div>    <script>        function cl() {            var c = '0123456789abcdef';            var cc = '#';            cc += c.charat(math.round(math.random() * (c.length - 1)));            cc += c.charat(math.round(math.random() * (c.length - 1)));            cc += c.charat(math.round(math.random() * (c.length - 1)));            cc += c.charat(math.round(math.random() * (c.length - 1)));            cc += c.charat(math.round(math.random() * (c.length - 1)));            cc += c.charat(math.round(math.random() * (c.length - 1)));            return cc;        }        function ling(num) {            for (var i = 1; i <= num; i += 2) { document.write('<p>');                for (var j = 1; j <= i; j++) { document.write('<span style="color:' + cl() + '">*</span>');                }                document.write('</p>');            }            for (var i = num; i >= 1; i -= 2) {                document.write('<p>');                for (var j = 1; j <= i; j++) { document.write('<span style="color:' + cl() + '">*</span>');                }                document.write('</p>');            }        }        ling(15);    </script></div></body></html>
相关推荐: 
js如何实现图片延迟加载?js实现图片延迟加载的方法代码
js时间相互转换:时间戳转为时间字符串(代码)
js中验证数字的方法总结
以上就是js实现打印一个彩色的菱形(代码)的详细内容。
其它类似信息

推荐信息