title: CSS Advanced Div Positioning. Auto Arrange to Grid
body: <p>i have an dynamic image gallery to display, using PHP... </p>
  
  <p><strong>My PROB</strong></p>
  
  <p><img src="https://i.stack.imgur.com/ynaL8.png" alt="alt text">
  the style &amp; positioning should be that if there is not enough space for a whole div, like in the image above,  then the DIVs in the row should position them like the following</p>
  
  <p><img src="https://i.stack.imgur.com/cMjD2.png" alt="alt text">centered and equi distant...</p>
  
  <p><a href="http://jsfiddle.net/u7qBz/1" rel="nofollow noreferrer">here is JS-Fiddle</a> basic template set, if somebody wants to try something on jsFiddle</p>