Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I can't tell you how responsive this will be with a 100 divs, but based on the earlier script here's something to get you at least started — <a href="http://jsfiddle.net/jgJsL/5/" rel="noreferrer">http://jsfiddle.net/jgJsL/5/</a>:</p> <pre><code>$.fn.bounce = function(options) { var settings = $.extend({ speed: 10 }, options); return $(this).each(function() { var $this = $(this), $parent = $this.parent(), height = $parent.height(), width = $parent.width(), top = Math.floor(Math.random() * (height / 2)) + height / 4, left = Math.floor(Math.random() * (width / 2)) + width / 4, vectorX = settings.speed * (Math.random() &gt; 0.5 ? 1 : -1), vectorY = settings.speed * (Math.random() &gt; 0.5 ? 1 : -1); // place initialy in a random location $this.css({ 'top': top, 'left': left }).data('vector', { 'x': vectorX, 'y': vectorY }); var move = function($e) { var offset = $e.offset(), width = $e.width(), height = $e.height(), vector = $e.data('vector'), $parent = $e.parent(); if (offset.left &lt;= 0 &amp;&amp; vector.x &lt; 0) { vector.x = -1 * vector.x; } if ((offset.left + width) &gt;= $parent.width()) { vector.x = -1 * vector.x; } if (offset.top &lt;= 0 &amp;&amp; vector.y &lt; 0) { vector.y = -1 * vector.y; } if ((offset.top + height) &gt;= $parent.height()) { vector.y = -1 * vector.y; } $e.css({ 'top': offset.top + vector.y + 'px', 'left': offset.left + vector.x + 'px' }).data('vector', { 'x': vector.x, 'y': vector.y }); setTimeout(function() { move($e); }, 50); }; move($this); }); }; $(function() { $('#wrapper li').bounce({ 'speed': 7 }); }); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload