title: CSS table with variable number of columns to fit to screen
body: <p>Basically the same question as "<a href="https://stackoverflow.com/questions/11238501/creating-a-html-table-with-dynamically-expanding-number-of-columns-to-fit-screen">Creating a html table with dynamically expanding number of columns to fit screen size</a>".</p>
  
  <p>However, I'm looking for a pure Javascript solution without third party libraries. I don't have access to them.</p>
  
  <p>The starting point is as follows:</p>
  
  <pre><code>&lt;div id="icons"&gt;&lt;/div&gt;
  
  #icons {
    display: table;
    width: 100%;
  }
  .iconBody { display: table-row-group; } /* May not be necessary to solution */
  .iconRow { display: table-row; }
  .iconCell { display: table-cell; }
  
  function loadValues() {
    // other stuff
    var iconTable = document.getElementById("icons");
  
    // TODO following lines are editable to suit the solution as necessary
    for (var i = 0; i &lt; icons.length; ++i) {
      addIcon(iconTable, icons[i]);
    }
  }
  
  function addIcon(iconTable,  icon)  {
    // TODO add solution here
  
    // Row addition example
    var row = document.createElement("DIV");
    row.className = "iconRow";
    iconTable.appendChild(row);
  
    // Cell addition example
    var cell = document.createElement("DIV");
    cell.className = "iconCell";
    row.appendChild(cell);
  
    // Icon addition example
    var iconImg = document.createElement("IMG");
    var iconImg.src = icon.srcPath;
    iconImg.addEventListener("click", someFunction);
    cell.appendChild(iconImg) ;
  }
  </code></pre>
  
  <p>This table has no headers/labels, just an array of icons for the user to select one from. The icons are of the same dimensions with each other, though the icons are stored server-side so I may or may not be able to obtain their dimensional values. These values will never change though. The application panel from which the page is displayed can be resized, so I want the number of columns this table has to fit according to the panel's current width without horizontal overflow.</p>
  
  <p>The application uses IE 11.212.10586.0 to display web pages.</p>