Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Alternative solution: DIV</p> <pre><code>&lt;style&gt; .floor{ width: 800px; border: 1px solid red; padding: 4px; margin: 6px 0px; } .app{ width: 110px; float: left; padding: 2px; margin: 0px 4px; border: 1px solid blue; } .spacer{clear: both; } &lt;/style&gt; &lt;? foreach( $floors as $floor ){ echo "&lt;div class='floor'&gt;"; for( $a=0;$a&lt;count($floor);$a++ ) echo "&lt;div class='app'&gt;{$floor[$a]}&lt;/div&gt;"; echo "&lt;div class='spacer'&gt;&lt;/div&gt;"; echo "&lt;/div&gt;"; } ?&gt; </code></pre> <p><img src="https://i.stack.imgur.com/105xW.jpg" alt="Table vs div"></p> <p><strong>EDIT 1:</strong></p> <p><img src="https://i.stack.imgur.com/JRbO1.jpg" alt="enter image description here"></p> <p>Limitation &amp; remark: </p> <ol> <li>you need provide the outer div(.floor) width to calculation</li> <li>in coding, 14 means left &amp; right x (app.border: 1 + app.padding: 2 + app.margin: 4)</li> <li>in coding, 800 means floor.width - ( left &amp; right x (floor.border: 1 + floor.padding: 4) )</li> </ol> <p>Coding:</p> <pre><code>&lt;style&gt; .floor{ width: 810px; border: 1px solid red; padding: 4px; margin: 6px 0px; } .app{ float: left; padding: 2px; margin: 0px 4px; border: 1px solid blue; } .spacer{clear: both; } &lt;/style&gt; &lt;? foreach( $floors as $floor ){ echo "&lt;div class='floor'&gt;"; // 14px = 2 x (app.border: 1 + app.padding: 2 + app.margin: 4) // 800px = floor.width - ( 2 x (floor.border: 1 + floor.padding: 4) ) $percent = floor( 1 / count($floor) * 800) - 14; for( $a=0;$a&lt;count($floor);$a++ ) echo "&lt;div class='app' style='width: {$percent}px'&gt;{$floor[$a]}&lt;/div&gt;"; echo "&lt;div class='spacer'&gt;&lt;/div&gt;"; echo "&lt;/div&gt;"; } ?&gt; </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