This article mainly uses js Code to implement random color blocks. For more information, see the following code: Random color blocks implemented by js, code directly.
/**/Js comment deleted
Koringz
* {-Webkit-box-sizing: border-box;-moz-box-sizing: border-box;} html {font-size: px;-webkit-tap-highlight-color: transparent;} body {margin:; padding:; font-family: "Helvetica Neue", Helvetica, Arial, sans-serif; font-size: px; line-height :.; color: #; background-color: rgba (,,,.);}. container {overflow: visible ;}. main {position: relative; width: %; height: px; margin: auto ;}. colorful {overflow: visible; width: %; height: % ;}. colorful> a {float: left; display: block; width: px; height: px; zoom :;}. colorful> a: hover {-webkit-animation: infinite s release-in-out start-roll;-moz-animation: infinite s release-in-out start-roll; animation: infinite s release-in-out start-roll;} @-webkit-keyframes start-roll {%{-webkit-transform: rotate (deg ); /* chrome */-moz-transform: rotate (deg);/* Firefox */-ms-transform: rotate (deg);/* IE */transform: rotate (deg);-webkit-transition: opacity. s linear; transition: opacity. s linear; opacity :.; filter: alpha (opacity =); zoom :;%{-webkit-transform: rotate (deg);/* chrome */-moz-transform: rotate (deg ); /* Firefox */-ms-transform: rotate (deg);/* IE */transform: rotate (deg);-webkit-transition: opacity s linear; transition: opacity s linear; opacity:; filter: alpha (opacity =); zoom :;%{-webkit-transform: rotate (deg ); /* chrome */-moz-transform: rotate (deg);/* Firefox */-ms-transform: rotate (deg);/* IE */transform: rotate (deg);-webkit-transition: opacity. s linear; transition: opacity. s linear; opacity :.; filter: alpha (opacity =); zoom :;}@-moz-keyframes start-roll {%{-webkit-transform: rotate (deg ); /* chrome */-moz-transform: rotate (deg);/* Firefox */-ms-transform: rotate (deg);/* IE */transform: rotate (deg);-webkit-transition: opacity. s linear; transition: opacity. s linear; opacity :.; filter: alpha (opacity =) ;}%{-webkit-transform: rotate (deg);/* chrome */-moz-transform: rotate (deg ); /* Firefox */-ms-transform: rotate (deg);/* IE */transform: rotate (deg);-webkit-transition: opacity s linear; transition: opacity s linear; opacity :.; filter: alpha (opacity =) ;}%{-webkit-transform: rotate (deg);/* chrome */-moz-transform: rotate (deg ); /* Firefox */-ms-transform: rotate (deg);/* IE */transform: rotate (deg);-webkit-transition: opacity. s linear; transition: opacity. s linear; opacity :.; filter: alpha (opacity =) ;}@ keyframes start-roll {%{-webkit-transform: rotate (deg);/* chrome */-moz-transform: rotate (deg);/* Firefox */-ms-transform: rotate (deg);/* IE */transform: rotate (deg);-webkit-transition: opacity. s linear; transition: opacity. s linear; opacity :.; filter: alpha (opacity =) ;}%{-webkit-transform: rotate (deg);/* chrome */-moz-transform: rotate (deg ); /* Firefox */-ms-transform: rotate (deg);/* IE */transform: rotate (deg);-webkit-transition: opacity s linear; transition: opacity s linear; opacity :.; filter: alpha (opacity =) ;}%{-webkit-transform: rotate (deg);/* chrome */-moz-transform: rotate (deg ); /* Firefox */-ms-transform: rotate (deg);/* IE */transform: rotate (deg);-webkit-transition: opacity. s linear; transition: opacity. s linear; opacity :.; filter: alpha (opacity =) ;}( function (window) {var document = variable Doc ument; function on (elem, evolap, eventhd) {var onevsp2 = 'on' + evsp2; elem [onevsp2] = eventhd;} function grc () {var val = [], I =; while (++ I <=) {val. push (Math. floor (Math. random () *);} return 'rgb ('+ val. join () + ')';} function fbc () {var el = document. querySelectorAll ('. colorful ') [], total = Math. floor (el. offsetWidth/) * Math. floor (el. offsetHeight/), df = document. createDocumentFragment (), a; while (total -->) {a = document. createElement ('A');. style. backgroundColor = grc (); df. appendChild (a);} el. appendChild (df) ;}on (window, 'load', function () {fbc () ;}) (window)
The above code is to use JavaScript to implement all the content of the random color small square. If you need it, you can refer to it.