title: HTML table with fixed (frozen) columns and headers
body: <p>I've been searching over the web for the way to make a table with fixed (frozen) columns and header.
  Seems like I finally found the solution and modified it to my needs.</p>
  
  <p>There original fiddle is <a href="https://jsfiddle.net/RMarsh/bzuasLcz/3/" rel="noreferrer">here</a>.</p>
  
  <p><a href="https://jsfiddle.net/guLuqfkh/" rel="noreferrer">Here</a> is my modified solution. I tested it in Chrome (version: 55.0.2883.87 m) and Firefox (version: 51.0.1).</p>
  
  <p>The problem is that it works not completely in IE (version: 11.0.9600.18427). During the horizontal scrolling a frozen part of the header is getting scrolled too. Could someone help me to make it working in IE?
  And one more question: is the approach safe to use? I mean if it's using some unspecified behavior, then some of the future browsers or even some of the modern browsers might display my table in a wrong way, and it's better to use a safe solution with a few different tables and synchronizing scroll position and rows height.
  <strong>UPD:</strong> one more question: how to make this work stable on the mobile devices? </p>
  
  <p>Here is some code that demonstrates the approach: </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-js lang-js prettyprint-override"><code>$(document).ready(function() {
    $('tbody').scroll(function(e) { //detect a scroll event on the tbody
     /*
      Setting the thead left value to the negative valule of tbody.scrollLeft will make it track the movement
      of the tbody element. Setting an elements left value to that of the tbody.scrollLeft left makes it maintain    it's relative position at the left of the table.    
      */
      $('thead').css("left", -$("tbody").scrollLeft()); //fix the thead relative to the body scrolling
      $('thead th:nth-child(1)').css("left", $("tbody").scrollLeft()); //fix the first cell of the header
      $('tbody td:nth-child(1)').css("left", $("tbody").scrollLeft()); //fix the first column of tdbody
    });
  });</code></pre>
  <pre class="snippet-code-css lang-css prettyprint-override"><code>.container {
    height:200px; 
    width:400px;
    overflow: hidden;
  }
  
  table {
    position: relative;
    background-color: #aaa;
    border-collapse: collapse;
  table-layout: fixed;
  display: flex;
  flex-direction: column;
  height: 100%;
  width: 100%;
  }
  
  
  /*thead*/
  thead {
    position: relative;
    display: block; /*seperates the header from the body allowing it to be positioned*/
  }
  
  thead th {
    background-color: #99a;
    min-width: 120px;
    border: 1px solid #222;
  }
  
  thead th:nth-child(1) {/*first cell in the header*/
    position: relative;
    background-color: #88b;
  }
  
  
  /*tbody*/
  tbody {
    flex: 1;
    position: relative;
    display: block; /*seperates the tbody from the header*/
    overflow: auto;
  }
  
  tbody td {
    background-color: #bbc;
    min-width: 120px;
    border: 1px solid #222;
  }
  
  tbody tr td:nth-child(1) {  /*the first cell in each tr*/
    position: relative;
    background-color: #99a;
  }</code></pre>
  <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
  &lt;body&gt;
  &lt;div class="container"&gt;
  
    &lt;table&gt;
      &lt;thead&gt;
        &lt;tr&gt;
          &lt;th&gt;Name&lt;br/&gt;123&lt;/th&gt;
          &lt;th&gt;Town&lt;/th&gt;
          &lt;th&gt;County&lt;/th&gt;
          &lt;th&gt;Age&lt;/th&gt;
          &lt;th&gt;Profession&lt;/th&gt;
          &lt;th&gt;Anual Income&lt;/th&gt;
          &lt;th&gt;Matital Status&lt;/th&gt;
          &lt;th&gt;Children&lt;/th&gt;
        &lt;/tr&gt;
         &lt;tr&gt;
          &lt;th&gt;Name&lt;/th&gt;
          &lt;th&gt;Town&lt;/th&gt;
          &lt;th&gt;County&lt;/th&gt;
          &lt;th&gt;Age&lt;br/&gt;123&lt;br/&gt;321&lt;/th&gt;
          &lt;th&gt;Profession&lt;/th&gt;
          &lt;th&gt;Anual Income&lt;/th&gt;
          &lt;th&gt;Matital Status&lt;/th&gt;
          &lt;th&gt;Children&lt;/th&gt;
        &lt;/tr&gt;
      &lt;/thead&gt;
      &lt;tbody&gt;
        &lt;tr&gt;
          &lt;td&gt;John Smith&lt;/td&gt;
          &lt;td&gt;Macelsfield&lt;/td&gt;
          &lt;td&gt;Cheshire&lt;br/&gt;123&lt;/td&gt;
          &lt;td&gt;52&lt;/td&gt;
          &lt;td&gt;Brewer&lt;/td&gt;
          &lt;td&gt;£47,000&lt;/td&gt;
          &lt;td&gt;Married&lt;/td&gt;
          &lt;td&gt;2&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;Jenny Jones&lt;br/&gt;123&lt;br/&gt;312&lt;/td&gt;
          &lt;td&gt;Threlkeld&lt;/td&gt;
          &lt;td&gt;Cumbria&lt;/td&gt;
          &lt;td&gt;34&lt;/td&gt;
          &lt;td&gt;Shepherdess&lt;/td&gt;
          &lt;td&gt;£28,000&lt;/td&gt;
          &lt;td&gt;Single&lt;/td&gt;
          &lt;td&gt;0&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;Peter Frampton&lt;/td&gt;
          &lt;td&gt;Avebury&lt;/td&gt;
          &lt;td&gt;Wiltshire&lt;/td&gt;
          &lt;td&gt;57&lt;/td&gt;
          &lt;td&gt;Musician&lt;/td&gt;
          &lt;td&gt;£124,000&lt;/td&gt;
          &lt;td&gt;Married&lt;/td&gt;
          &lt;td&gt;4&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;Simon King&lt;/td&gt;
          &lt;td&gt;Malvern&lt;/td&gt;
          &lt;td&gt;Worchestershire&lt;/td&gt;
          &lt;td&gt;48&lt;/td&gt;
          &lt;td&gt;Naturalist&lt;/td&gt;
          &lt;td&gt;£65,000&lt;/td&gt;
          &lt;td&gt;Married&lt;/td&gt;
          &lt;td&gt;2&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;Lucy Diamond&lt;/td&gt;
          &lt;td&gt;St Albans&lt;/td&gt;
          &lt;td&gt;Hertfordshire&lt;/td&gt;
          &lt;td&gt;67&lt;/td&gt;
          &lt;td&gt;Pharmasist&lt;/td&gt;
          &lt;td&gt;Retired&lt;/td&gt;
          &lt;td&gt;Married&lt;/td&gt;
          &lt;td&gt;3&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;Austin Stevenson&lt;/td&gt;
          &lt;td&gt;Edinburgh&lt;/td&gt;
          &lt;td&gt;Lothian &lt;/td&gt;
          &lt;td&gt;36&lt;/td&gt;
          &lt;td&gt;Vigilante&lt;/td&gt;
          &lt;td&gt;£86,000&lt;/td&gt;
          &lt;td&gt;Single&lt;/td&gt;
          &lt;td&gt;Unknown&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;Wilma Rubble&lt;/td&gt;
          &lt;td&gt;Bedford&lt;/td&gt;
          &lt;td&gt;Bedfordshire&lt;/td&gt;
          &lt;td&gt;43&lt;/td&gt;
          &lt;td&gt;Housewife&lt;/td&gt;
          &lt;td&gt;N/A&lt;/td&gt;
          &lt;td&gt;Married&lt;/td&gt;
          &lt;td&gt;1&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;Kat Dibble&lt;/td&gt;
          &lt;td&gt;Manhattan&lt;/td&gt;
          &lt;td&gt;New York&lt;/td&gt;
          &lt;td&gt;55&lt;/td&gt;
          &lt;td&gt;Policewoman&lt;/td&gt;
          &lt;td&gt;$36,000&lt;/td&gt;
          &lt;td&gt;Single&lt;/td&gt;
          &lt;td&gt;1&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;Henry Bolingbroke&lt;/td&gt;
          &lt;td&gt;Bolingbroke&lt;/td&gt;
          &lt;td&gt;Lincolnshire&lt;/td&gt;
          &lt;td&gt;45&lt;/td&gt;
          &lt;td&gt;Landowner&lt;/td&gt;
          &lt;td&gt;Lots&lt;/td&gt;
          &lt;td&gt;Married&lt;/td&gt;
          &lt;td&gt;6&lt;/td&gt;
        &lt;/tr&gt;
        &lt;tr&gt;
          &lt;td&gt;Alan Brisingamen&lt;/td&gt;
          &lt;td&gt;Alderley&lt;/td&gt;
          &lt;td&gt;Cheshire&lt;/td&gt;
          &lt;td&gt;352&lt;/td&gt;
          &lt;td&gt;Arcanist&lt;/td&gt;
          &lt;td&gt;A pile of gems&lt;/td&gt;
          &lt;td&gt;Single&lt;/td&gt;
          &lt;td&gt;0&lt;/td&gt;
        &lt;/tr&gt;
      &lt;/tbody&gt;
    &lt;/table&gt;
    
  &lt;/div&gt;
  &lt;/body&gt;</code></pre>
  </div>
  </div>
  </p>