javascript实现简单加载随机色方块_javascript技巧
程序员文章站
2022-04-02 15:27:05
...
用碎片加载小方块实现简单的随机色块,直接上代码:
效果图:
效果图:
具体代码:
koringz
css代码:
* { -webkit-box-sizing: border-box; -moz-box-sizing: border-box; box-sizing: border-box; } html { font-size: 10px; -webkit-tap-highlight-color: transparent; } body { margin: 0; padding: 0; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: 14px; line-height: 1.42857143; color: #333; background-color: rgba(211,232,132,0.8); } .container { overflow: visible; } .main { position: relative; width: 90%; height:200px; margin:auto; } .colorful { overflow: visible; width: 100%; height: 100%; } .colorful > a { float: left; display: block; width: 50px; height: 50px; zoom:2; } .colorful > a:hover { -webkit-animation:infinite 2s ease-in-out start-roll; -moz-animation:infinite 2s ease-in-out start-roll; animation:infinite 2s ease-in-out start-roll; } @-webkit-keyframes start-roll{ 0% { -webkit-transform: rotate(0deg); /*chrome*/ -moz-transform: rotate(0deg); /*火狐*/ -ms-transform: rotate(0deg); /*IE*/ transform: rotate(0deg); -webkit-transition: opacity .3s linear; transition: opacity .3s linear; opacity: .5; filter: alpha(opacity=50); zoom:1; } 50% { -webkit-transform: rotate(180deg); /*chrome*/ -moz-transform: rotate(180deg); /*火狐*/ -ms-transform: rotate(180deg); /*IE*/ transform: rotate(180deg); -webkit-transition: opacity 1s linear; transition: opacity 1s linear; opacity: 1; filter: alpha(opacity=100); zoom:2; } 100% { -webkit-transform: rotate(360deg); /*chrome*/ -moz-transform: rotate(360deg); /*火狐*/ -ms-transform: rotate(360deg); /*IE*/ transform: rotate(360deg); -webkit-transition: opacity .3s linear; transition: opacity .3s linear; opacity: .5; filter: alpha(opacity=50); zoom:1; } } @-moz-keyframes start-roll{ 0% { -webkit-transform: rotate(0deg); /*chrome*/ -moz-transform: rotate(0deg); /*火狐*/ -ms-transform: rotate(0deg); /*IE*/ transform: rotate(0deg); -webkit-transition: opacity .3s linear; transition: opacity .3s linear; opacity: .5; filter: alpha(opacity=50); } 50% { -webkit-transform: rotate(180deg); /*chrome*/ -moz-transform: rotate(180deg); /*火狐*/ -ms-transform: rotate(180deg); /*IE*/ transform: rotate(180deg); -webkit-transition: opacity 1s linear; transition: opacity 1s linear; opacity: .5; filter: alpha(opacity=50); } 100% { -webkit-transform: rotate(360deg); /*chrome*/ -moz-transform: rotate(360deg); /*火狐*/ -ms-transform: rotate(360deg); /*IE*/ transform: rotate(360deg); -webkit-transition: opacity .3s linear; transition: opacity .3s linear; opacity: .5; filter: alpha(opacity=50); } } @keyframes start-roll{ 0% { -webkit-transform: rotate(0deg); /*chrome*/ -moz-transform: rotate(0deg); /*火狐*/ -ms-transform: rotate(0deg); /*IE*/ transform: rotate(0deg); -webkit-transition: opacity .3s linear; transition: opacity .3s linear; opacity: .5; filter: alpha(opacity=50); } 50% { -webkit-transform: rotate(180deg); /*chrome*/ -moz-transform: rotate(180deg); /*火狐*/ -ms-transform: rotate(180deg); /*IE*/ transform: rotate(180deg); -webkit-transition: opacity 1s linear; transition: opacity 1s linear; opacity: .5; filter: alpha(opacity=50); } 100% { -webkit-transform: rotate(360deg); /*chrome*/ -moz-transform: rotate(360deg); /*火狐*/ -ms-transform: rotate(360deg); /*IE*/ transform: rotate(360deg); -webkit-transition: opacity .3s linear; transition: opacity .3s linear; opacity: .5; filter: alpha(opacity=50); } }
js代码:
(function (window) { var document = window.document; function on(elem, evtnm, eventhd) { var onevtnm = 'on' + evtnm; elem[onevtnm] = eventhd; } function grc() { var val = [], i = 0; while (++i 0) { a = document.createElement('a'); a.style.backgroundColor = grc(); df.appendChild(a); } el.appendChild(df); } on(window, 'load', function () { fbc(); }); })(window)
希望本文所述对大家学习javascript程序设计有所帮助。
上一篇: css怎么取消position
推荐阅读
-
javaScript和jQuery自动加载简单代码实现方法
-
JS实现简单的顶部定时关闭层效果_javascript技巧
-
两种方法实现在HTML页面加载完毕后运行某个js_javascript技巧
-
JS操作CSS随机改变网页背景实现思路_javascript技巧
-
javascript 实现简单的table排序及table操作练习_javascript技巧
-
js history对象简单实现返回和前进_javascript技巧
-
js实现DIV的一些简单控制_javascript技巧
-
js或者jquery判断图片是否加载完成实现代码_javascript技巧
-
js简单实现让文本框内容逐个字的显示出来_javascript技巧
-
用js实现计算代码行数的简单方法附代码_javascript技巧