JS-鼠标彩色拖尾小效果

时间:2023-03-08 21:49:43

实现步骤解析:

* 这原本就是一个鼠标后面跟随一串小方块的效果,
     * 后来我就想,运用之前学的随机数的案例把小方块的颜色做成彩色的,
     * 并且每一个小方块的色彩是随机分配而不是我自己手动填写的。

 function getColor(){
var oMath = Math.floor(Math.random()*255);
var rgb = "rgb("+
Math.floor(Math.random()*255)+","+
Math.floor(Math.random()*255)+","+
Math.floor(Math.random()*255)+")";
return rgb;
}

随机颜色值封装函数

* 等实现了以后,我又感觉虽然颜色都不一样了,但是只要页面不关闭他们就永远被分配了这个颜色不能变化了
     * 于是我又想让其颜色是随时随地随机变化随便什么颜色了。
     * 于是就将随机分配颜色的函数给了鼠标移动事件。

  aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAjoAAABlCAIAAADLbd6cAAAT3UlEQVR4nO2dv2scSRbHG5TM3l+hXCDwBgaB/BcoERLWRhsYlMiwkVjQ6OBYEBgObND4IsMlXmwYDMeKY0E6WGwLicUYcXBYcqJLBnMIBA4WR47mguof9ePVe9XT3dPVM1/xCeyZmurXVd317ffqdVUyHl8AAAAAkZO0bgEAAAAgArkCAADQASBXAAAAOgDkCgAAQAeAXAEAAOgAkCsAAAAdAHIFAACgA0CuAAAAdICqcjV6s7y6v7A6HLR+JgB0iNGr07trb+8+ftf8sZ7u9O4fd6ZaALxUlKujF4OF1f2F1f3Ns+rWXG2u7i8cXLXfKKDzvDu/u/Y256d3bdtj8/7nH5Rt56fNHuhocK/X6/V2juuu+fh+r9frhShWWrLXu/fjdfstDzpMTN4V5ArUQeq4tCdXp49lHZqOd3W80+v1vh1cN1P/9Y/3er3ezlOuTK5VkCtQmZjmriBXoAaU43L686fWbAiRq2lwfL/X690bHDV3iOvBt7zrdrzTjG8H5hLIFZgx3v00pTkhL3HI1dHg3hQcmqc7rNt0vAOnCtQGIVdnQ99c1OCgiPsNDvbVrNUCGQwcvVle3V9+cZtFC/cX1H+pYgs6llydDfVvC6vCjAziyzC53svZ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E609Q1vHdFPRtpwLsSMS84d5pB/5tkFE7xPxPlfdywXDHelXsU37VrFvOdJmFb2Fm4T8Tehex8T5esefYbnSfrS5wiOpW4KSTpeeWS5pvPKB94YfpCszCPTJaQK7M71p49CWkHzySux8ig7uZPs325CujNwItWunG60dS+IKRTRsrFpZsI3lVX6MQiTCHUtFBTR6Hv57IvkIE4QG86VF8zMBVmOqgI76obzIZcSfPGMw85rR30ThuID/QmwcQrsuuBjXKvCcfg2cRgQzyEbCDC0e5+V3o4oo1V3aLBn9ncclALTAB6kyQNudPzc/7bPxviuIdyeFfdYEbkaq5v4xRnJmN+n8RnAPQmxTZ2EwYAADC/dNW7Go8vAAAAzA/xeleQKwAAADnwrgAAAHQAeFcAAAA6QMzeFbcgR+sNBwAAYJrE7F0ZrzVYitV6wwEAAJgmMXtXGc4G0pArAACYN2L2rkw3C3IFAABzTBe8K8gVAADMPfCuAAAAdIDueFfmYlytNxwAAIBp0gnvyt1uDnIFAADzRSe8qyf6PrCQKwAAmEO64V25W3613nAAAACmSSe8K6RaAADAvNMJ7wpyBQAA8w68KwAAAB0A3hUAAIAO0AnvansNawYCAMB80wHv6nl/EUvcAgDAnBOzd6VvIGJksUOuAABg3ojZu8L2jAAAAFJi9q44Wm84AAAA0yQhP/33f/7RumUAAABADi1XAAAAQFTAuwJluLr/Xf+bv11VKAAAABPxf/FQaahyEFOQAAAAAElFTkSuQmCC" alt="" />
     * 之所以这么废话的原因,是我想记录下自己是怎么一步一步实现这个效果的。
     * 因为通常情况下,我们都是拿到一个效果后就蒙了,
     * 其实如果从内向外或者从外向内一层层剖析,然后一步步实现,不自乱阵脚,是可以实现最终的宏伟蓝图的。
     * 代码中:
     * getColor()函数是一个生成随机颜色值的函数,在需要给元素填充颜色的地方,直接调用就ok;
     * 其代码核心是 Math.floor(Math.random()*255) 这句,他获取到的是0-255之间的任意一个值,
     * 然后把r,g,b三个值分别用这句代码代替,凑成一个整的颜色值字符串赋给变量,最后弹出就ok了。

  aaarticlea/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BDAe4IBph+9NVyFtzpWt7W1MoXSBEsaXtjoA9hw1gz2EAAAgVKB0AoP9A6QAA/QdKBwDoP1A6AED/gdI1QhRTTAHYHbpRuptne8cd2mI2D5QOgKCA0jUClA6AoIDSNQKUDoCg8FW6+fxkb/JqkaaLxSzfrFlxBvn66t527+Zn8+1XnCGmxOTVgv+3wpYyb0d8AWsMX1/dY7ZMXBh2VzoRJw/DJbFbULZk0tHcL1V3cAMANEA5pRvPpT3pOTm7eaZsV1/IUJ1Kp41B0NktXk3IcuZ+stIpBoOq2HVgBwfADlJG6cRWEjuS6wjTMkX4pG3/DNmro9IZYtgqXR4GGYMRm7mfvJRa3uNbNfdjR9TNG9q3gwNgBymndIJI8bJFSdh8frIn5LD1KJ02hkzplKyZO4MVi7mf2g0n7Z1J6Rpl/gIAaIVSSifKFgfXcaZLYNNNWovSaWNwOYMV21a6bm06YktbKB0AXQClI7FuGk7103HloXQABEW9Sre5ebanDsXSxTTjoapOsV62sJROb0PDIJQuih1rAegpNSsd0UfmW0wc0yhGcoNSOqu3saJ0WRtQnU3Svh0cADtIzUqnS2DlcU9lugk1tGos0KnSacz9qLFXTXpbVFf7dnAA7CC1K90mpabUETM8RLETZOjbeHLCN+WKqcJOMXTWTyeInWxCqp1H0rodHAA7CPYyKQFtDFpytUPrdnAA7CBQuhIQs+3ygx6C1ZUdHAA7CJSuBLrU1W9otSs7OAB2EChdSZTl/Ug/AQgXKB0AoP9A6QAA/ef/kN7ZrU3L48EAAAAASUVORK5CYII=" alt="" />
     * onmousemove函数中,是当鼠标有移动的时候会发生的事情,
     * 本来i的for循环是在这个函数的外边的,我为了让小方块可以随时随地换随机颜色,就把他放进了鼠标事件里边,每当鼠标移动一次,就从新调用一个颜色值,这样就会在鼠标移动的时候变颜色了。
     * 而多个小方块可以跟随的原理则是:
     * 所有小方块的属性为绝对定位

  aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAASQAAAA2CAIAAADh8nOfAAAHKUlEQVR4nO2dv0s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qvUv3Op9rFklOgv5ROdT3BayHDAQNte5AWqxMZK2jo5JVMpIgDpTIbaR3f2UIbFlAXnJhyCzcft11TAM4715G/HM+XY2FBsSIbfme2P6Lys3tbMAig2JnKnYPnXjmR+dDUESIq/OhiC5I6/OhiC5A50NQRICnQ1BEmL+nS3Xf2wHmSfm3tmC/Bm5681AHU7siCKBQGejgMTm8w2aJMX275dJ692k9cvtT2jvz7/+a72bOHwZp/6ZIyD/A8GfkfLVOaf5AAAAAElFTkSuQmCC" alt="" />
     * 其left和top值在鼠标变换时接受js传值改变。而值变化的规律是:后一个的left值等于前一个的offsetLeft值;top值等于前一个的offsetTop值

  aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAjkAAAAzCAIAAAD6jY51AAANjklEQVR4nO2dv27juBbGF9jGu88wZeoU2Xb8ArcKMAi2dul2DBuYbYN0aZRbGgFSbJF0KWbgYhAYgzTBwsBWmSLGzsLFbJFFcB9Bt6Bk8c85h5RISaRygl+ROLRkkx/1kUdH5A95vmEYhmGYmPmh90/AMAzDMDTsVQzDMEzssFcxDMMwsdOPV22zo9FoNJpe9P79GUbAmmSYmOnFq26z8Wg0Go1GJ6tGRyguK8XPUbateYTtfCy9P8rLU3b6249v91xnfX+ewdO3Jv3pUtWrE+VUq/oFGJK7j2cH52cHHz9pv6d1irAE9KqL6Uj/wTTqOYZNwqvur398+9u7+4Zv78irVtPmV+cUSEeTbvz9/t/lm3+X/9n+z/xvV16lflOgSq0FPEFFq9WA8tPH6MGDbw+ZZiTHD1+SO0VY2vWq0Wg0Gs+3oT/0NjsKdIW9mEbqVXuyU/aq5qSoSZjCpd7gXqV967a8SkxAiUu/tYAvr8erhHnIv6d1irCE9ir5KlDGAcbZbdgPzV4VilfhVYlpEqA0qn/+/OvrXc9eZT14q2ff5I6iXZ0En8/V5vHk1w8//fexyXvZq0xqe9VKGanKijGuC/l+pLMvpo5zNUGLwsaYdzXVh0W268L+3oP5ITWa96vd+rCK0WWz3f5fj+/eyuE7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Vnd7K+ZV/RpVe9AIG+u49nB+fZ8unm2AgPdk+N3Ar1prT5it7t93mfUJez5kkfZduLKXJHztrtqzOWI9b6XlWOsMz/Ps8mqk+I3HEtr6FIKCduIIl8ivVsQlka7FX2g1u/ha0SnJdpcEtBbjQg8M+tGKJoaTy9ChWMrSZd9WCZngLJk1U9OGqJLkZ7VQyyr+jOq4Ak9VCPTxU66TIPEHnIH3kMpfwxR4uWMuWhptMTTFJEtzcXPsEvPRtLt9G/YIl4QErHCOIZyevGHalyISVzhoQkvktHgMOAeh4g8S3sbQHHQ9zv4mAn6jZnfXiihfi8qxateGNdwKKR7C016awHp7Njp3DTJCk5ICVd+Twxyb6DPEAZeVL1os2lihtX9VMBq/r0fMSq7rPAakMqTWVI2TRS126PDdkK6NvU+nN82/k47LwqN7wEm9+oxczsCZFoDmRV2L2qejvlVcS3cGsLs2PX7rTGuTp/FnhgooUI5VWWiThRk+56cM6tQIo5aJKSnM2rHE8Rv+wpTK9S5kzmY7/Yiy6U9dCxV0VBEmssuRBoHSYmAdpeD7AOPcue6R2f56VqU0yXfe/esVf11mnRSRUzRNirmHjoxqvkaEGXzwJHRBJ7gqDI8b1guXxM7Lyu/auYuOnWq8IM0dir+vOqdldPZ+KCvYqJh05jgIFI0qsYhmGYVwV7FcMwDBM77FUMwzBM7LBXMQzDMLHDXsUwDMPEzv8BS0gMLNsyDzUAAAAASUVORK5CYII=" alt="" />
     * 注意的是,在这个循环中,是倒着循环的。

  aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAY0AAAAYCAIAAACJGTbCAAAGf0lEQVR4nO2cvW4iMRDHr3R4Bp6Ck+h4gaNGVHmALdKcRCQ6HoBmoYlERxVFKei2iKKAFEUIIUUpkmYVnVB0KY7iHoEr7N31x9hjWC+74Rz9m/OZ9azX/u3MeODbbrf28vLyqrK+lW6Bl5eXl1meU15eXlVXpTg1CkgnKt+MU1YcNgghJBiVbonXfyBnO9qOU6+dbv8s1fi1iFuahS1CCAmi0if3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bSnHdCqn9ojy9EaKf0eswTFse/qAXfhTcgCeJxcOflYXsmWWA2CVIOLInzINcSRO7beihEiF+lNKRQKQtMpng+cUuqY5fTydp6Hf8lFOV9Fce6GcYgnpL8cpMOVknPC410p3bNTJUc5WGKfAi1g5bkw2nLLWoZzab0Up/lRyugelqKT8lCsbHEj7UGwKrPJyyibuQziFFiWsphcs9FsM5aM6mo0yJrDycgqI8I8d94FeAxb3ya6HeDV4WWTPwia1iRgM4sN4TVt/ikccxBfDMWUVOLXPioLyUwxJVud9LmxwItM2L7YuQcmaa/LoWO0Vevi9uVk024vpR1phkP2XnDVP3CvnnMqeX/IiOmYeXcyaqy0yp1KPGjISLRpohPEo0G7dxKMxvQDhIdBSeBQilikzw0DH5BR7Rmg8rltR7CwLKLFOMlNy/dT9nWsbXKmo875MBtaM5YIDuYTKrkYUXyjLQXs+GD6qye/NzUIN+txySnNYfuTviIEV55raKNDX0JzZK9M+CggJgo4WB1m8oHTAh4BDP+m8zwARi8IF2BJDJn5vTrEaS7QcPLtZaalYrCikfoorRAASVY5scKnC6qcymVkjllDJ3Sxr2cHzLEHUbwJxI6BquKQulds8ulyaGPdaJXyXVdzkwqtJ4ZT61G05BfhusBm6sgNsCLWEyp5T+iQXgqoyOJXZoC4VfEWZ69F3651YkaCtRM9jg9ulW3A9+lHkv9/nhQt+nxVc+JNDzPcs9dv1FbDB7vt9SDhfDU7530vwwgWeJ9DGaq0c3lUp6+1bBRt2O6vjPH0xaqaqcCoNXqr4YvSqhPSVDRX7rauEEWX+6GMVbNAfOoviiyQO/v2pI8r/nqcXIiW9VS1PykuU9Y7O/zt5Xl5eXuXKc8rLy6vq+gf1c6J3991a6QAAAABJRU5ErkJggg==" alt="" />
     * 最关键的是,第一个的值跟随鼠标的值+页面滚动上去的值。

  aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAATgAAAAwCAIAAAAKOfHkAAAF+ElEQVR4nO1cu5XjOgxlKc4dTeganDhyBY7cgRqYczbYAhxOFw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HcFZNeGp5Q8HZb+w9hBa8kPR0Rwc5x0t7nWGEjDRF1wwBNecZKf0qNefAQ+gfgbiJwmv8bwAaF2fbUedp/FBNbpevWlFTRTDvDJst2NDPM1S6IiG7mvzCjgxBTDfgwQpvJqiZypgLhEJCao6WrIGoVYAlajbKHtBj0fQJPuTF27thgZpD/lL8yIcRVRVq78dLzoIRdW6jlla0RdTpau17VD/V3G+LX2oWjKgvYAuzLIyoKpiI2vjn4EbUvdAMUQ2Gnwy3uwQGgyHC379/IhhRDYbqYEQ1GBrAnkS1cqEGQyZ2JKqVC2WhUIVQdIjweFNVe6SqKGAHcaJaudAA1ZcLFRsiPWTnz3v9p6+kJCxkBw2iOmflQjf2o3B2auMQ2CfHsnYoCCEJS9mhDFGtXOjmiVGTUGgI5vYfQ9RSdlhJVCsX6skArdhNlAuVHIIsv0bYQRF0PdEcCunYAaxbtIKoVi4UnPhQlybKhW4fgihC37ephah8PVGWqFp2gL9PXkxUKxeK3tVsudD1Q7AOmmMHDjr1RBkJFe0AflC1lKhWLjS86y3KhUoMUfAZVaeeKC3h7nZYSlQrF+rhXcqFSgxR82ZSVplCUsL97aBDVCsXitxbR7lQiSGMqGXtsIqoVi40c9BGyoVKDJHjoCurk+jUE+VT313tsHgzycqFDnijcqESQzAOuuUUmk490YyHFCU7gAVHV7yesXKh0b9AO6DK1lUuVGoINivh7VAUfD1ROBzMGqnZAS44uu7Ag5ULhRRpsVyo2BAZjw+cHQqDqSfKEVXRDlDB0Ya/R32PKoSvFo7XGVQBFRw1ov62cqGGSkAUHG2dqNPV2veo71Iu1CAIouCoEXVvotb4wbqhOjRMVIPh5wAgavqTwWCoDUZUg6EB/ANV4hUE1lFOfAAAAABJRU5ErkJggg==" alt="" />
     * 因为,鼠标的xy坐标值,只是鼠标相对于电脑屏幕(这么说更形象化,其实是根据浏览器界面)的值。
     * 而小方块或元素的xy坐标值(即left,top)则是根据的整个document||body页面,
     * 一旦页面发生滚动,小方块和鼠标的xy值将不再重合,而他们之间的差距就是scrollLeft和scrollTop;
     * 所以,最终的left、top值就是鼠标x、y值与对应的scrollleft、scrolltop值之和。

  aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAewAAAAuCAIAAABlH708AAALo0lEQVR4nO1dvU4kORC+cO6egyfYgGyegIQEXbQPMAEhSJuRTDZJz4UICRHdbkSwK6KVGAmhFiK9ZJBWQuiSk3gGLnB3u22Xq8rtn+mGGn3B7ozptl1VX5fL1a7f3t4eBQKBQDBR/LbzHgjeGZ6qT7PZbLZY77wnAsFHgJB4DzdHs95ncbPr/owL64UxOz6Ovq7mqsXRze77LPCBlGZ8gxCM2PR+fl/urZZ7339Y/x7PLSZP4jeLNHzR+I8eTUp1lymDa7S5PXGvLBQRzE+ejO+bh8qoeKEdRfcpr1ojIvGRm96vurIY9rDejOoWQuIKytQ/VU9Z7/I+sF7k5GgSiCwUHcyra+SbEcCkv53xeK8zmDTjG+AYu+kphlWs2v/3eG4hJK5AKOLONWlMGC+Jt/zYMsLTyRzwzXn45+jPL7//9U+m/lsTeF3NPyyJFzG9CGlOlsRf7j8f3O4f3z+b329Wt/sHm6uX7puHq+Pb/YMOdxujfX12cPv524PRzLkmCXzhyZGxsV6D1cWjSWaorv8p79x5R+GhqpsF5uB40EW0kTH6rI61vkZk8VR9Uh3uten1nykL1Wyxjg2kxJE4orRsuSCyWC+ab3ptYAWA+8CQZpoGYzG9GGluLzSrbi/2VsvTrf71V13trarz1zYkslqq/7YNfpyultafvL1+PbSaobewBOrqs88TV7Tb5+tHRco9FrYY3OVxReL3Z1abVc2eQUOPAcNmkLipyqa6K/qDNeXkKbkmRQAbBbwgXS9mgU4oMBsg1wwncXQUQGx0Nptp4bJloe4yn8eF5oebPaG0rD0DQhaKxE/s6dTXpA2HkmaCBiMyvWzrKkXih5fLlsF9PH7xs/nv5vzSasBEa1+OUfvDKfXdfuNHG9+c1V2bh6tjg+U3q1uzQd3Sd9dMfWM57F406t7rtLsUJUhc+2XGFZqnGalJzLugePj7j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FxEBqy64Oaow/ceAzz3kRez79qE774m4IXQYvauT82RxViK2ftlkd+yCpI4o1Z9U1MtR636eKDZKS/3n7uISn1nh8jbyshC4nFgkbhy3xq+uzkKdUJDwscTIPEEyUgxxewDSFwP3FqRCInnFxYNNok3O5wTJHG1dXl8/6y8cjOxREXA0aB5ChKPCqfQVwBULSDy8PiWKpxCa7Y2AF57YH548biIcAraqxASpx5RuyVxbijD/KtucmhZMEi8XDgFWWHktaxoYdEASPwViJn8/L7cW1XnW6vk8VhA5Ik/f9vsH2yuXrpkQf2TvY3ZOuYJCyW7q+bQjU3yCo6qNetfPkHEkzjzHcg2Z6vLP3PbIEWBm3H1/zDtxiY5CiaJs2ZjZyROatR64TCpb+fTLwtCBAF2EUfiiCwKWFa8sEg4JA7kFKZKA2/mp2h2SoP67OD2bHXn7kYape6zhFO04M0P5PJ4rZq4Apz3VvpVFzgWAS4sFosjr9Ond/y8U2R+6DTtkOrmxCi4r+o4N/JVu98JiVMaBf46s/1ZXBZM5vX2IVmtelQWBS2rQHZKH303/NXyvpvgeHiCiraO5Kni9BubyuMGudjg8VWtnPGkJP5oU4NPCTCrxq7gqlqOHCAO3CRrzsICHqmvgZme7OYsup9Qs0dGEfC+pXmvLCQeBVwnnYcZKA5EFqyNa7QPqUickMU0LAuBS+KGl+2+1+P7koN2JndA4u8bUS+MCAQCDyZhWUUrZDaP7fQvEgqJT0DVBILJYRKWVbZWfa7liJD4BFRNIJgcJmFZZUk811FiQuITUDWBYHKYhGUVDadkw0cncYFAIJg0hMQFAoFgwhASFwgEggnjfz1Pyrx//VQ6AAAAAElFTkSuQmCC" alt="" />
     * 另:
     * 这个代码还需要最后的封装处理。为了很好的体现我的制作思路我就不封装了。以后用到了可以拿下来再自己封装

源码:

 <!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>鼠标彩色拖尾小效果</title>
<meta name="author" content="郭菊锋/702004176@qq.com"/>
<style type="text/css">
*{margin: 0;padding: 0;}
body div{
position: absolute;
width: 10px;
height: 10px;
/*margin: 10px;*/
/*background: rgb(255,255,255);*/
}
</style>
<script type="text/javascript">
window.onload = function(){
function getColor(){
var oMath = Math.floor(Math.random()*255);
// console.log(maTh)
var rgb = "rgb("+
Math.floor(Math.random()*255)+","+
Math.floor(Math.random()*255)+","+
Math.floor(Math.random()*255)+")";
return rgb;
}
// console.log(getColor())
var oDiv = document.getElementsByTagName("div"); window.onmousemove = function(ev){
for(var i=0;i<oDiv.length;i++){
oDiv[i].style.backgroundColor = getColor();
}
var ev = ev || window.event;
var oScrollleft = document.documentElement.scrollleft || document.body.scrollLeft;
var oScrolltop = document.documentElement.scrollTop || document.body.scrollTop;
var oLeft = ev.clientX + oScrollleft + "px";
var oTop = ev.clientY + oScrolltop + "px";
// for(var a = oDiv.length;a>0;a++){
// oDiv[a].style.top = oDiv[a-1].style.top;
// oDiv[a].style.left = oDiv[a-1].style.left;
for(var a = oDiv.length-1;a>0;a--){
oDiv[a].style.top = oDiv[a-1].offsetTop + "px";
oDiv[a].style.left = oDiv[a-1].offsetLeft + "px";
}
oDiv[0].style.top = oTop;
oDiv[0].style.left = oLeft;
} }
</script>
</head>
<body>
<h3>鼠标移进来试试</h3>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
<div></div>
</body>
</html>