title: Fixing header with column filter dropdowns in jQuery datatables
body: <p>I've got a datatable with a fixed header and column filter dropdowns which extend when hovered. But the dropdowns don't extend as they should. I've traced the problem to scrollY and scrollX in table initialisation.  If I remove both scroll commands, the dropdowns work well, but the header is no longer fixed, and I need it to be fixed. I've tried using sScrollXInner and sScrollYInner, which do allow the column filter dropdowns to work, but again, the header is no longer fixed. I've also tried a number of 'z-index' options with 'relative' in CSS, but nothing seems to work.  Any ideas?  </p>
  
  <p><strong>HTML :</strong></p>
  
  <pre><code>&lt;table id="example" class="display" cellspacing="0" width="100%"&gt;
        &lt;thead&gt;
          &lt;tr&gt;
            &lt;th&gt;Name&lt;/th&gt;
            &lt;th&gt;Position&lt;/th&gt;
            &lt;th&gt;Office&lt;/th&gt;
            &lt;th&gt;Age&lt;/th&gt;
          &lt;/tr&gt;
        &lt;/thead&gt;
        &lt;tfoot&gt;
          &lt;tr&gt;
            &lt;th&gt;Name&lt;/th&gt;
            &lt;th&gt;Position&lt;/th&gt;
            &lt;th&gt;Office&lt;/th&gt;
            &lt;th&gt;Age&lt;/th&gt;
          &lt;/tr&gt;
        &lt;/tfoot&gt;
        &lt;tbody&gt;
          &lt;tr&gt;
            &lt;td&gt;Tiger Nixon&lt;/td&gt;
            &lt;td&gt;System Architect&lt;/td&gt;
            &lt;td&gt;Edinburgh&lt;/td&gt;
            &lt;td&gt;61&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td&gt;Garrett Winters&lt;/td&gt;
            &lt;td&gt;Accountant&lt;/td&gt;
            &lt;td&gt;Tokyo&lt;/td&gt;
            &lt;td&gt;63&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td&gt;Ashton Cox&lt;/td&gt;
            &lt;td&gt;Junior Technical Author&lt;/td&gt;
            &lt;td&gt;San Francisco&lt;/td&gt;
            &lt;td&gt;66&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td&gt;Cedric Kelly&lt;/td&gt;
            &lt;td&gt;Senior Javascript Developer&lt;/td&gt;
            &lt;td&gt;Edinburgh&lt;/td&gt;
            &lt;td&gt;22&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td&gt;Airi Satou&lt;/td&gt;
            &lt;td&gt;Accountant&lt;/td&gt;
            &lt;td&gt;Tokyo&lt;/td&gt;
            &lt;td&gt;33&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td&gt;Brielle Williamson&lt;/td&gt;
            &lt;td&gt;Integration Specialist&lt;/td&gt;
            &lt;td&gt;New York&lt;/td&gt;
            &lt;td&gt;61&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td&gt;Herrod Chandler&lt;/td&gt;
            &lt;td&gt;Sales Assistant&lt;/td&gt;
            &lt;td&gt;San Francisco&lt;/td&gt;
            &lt;td&gt;59&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td&gt;Rhona Davidson&lt;/td&gt;
            &lt;td&gt;Integration Specialist&lt;/td&gt;
            &lt;td&gt;Tokyo&lt;/td&gt;
            &lt;td&gt;55&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
            &lt;td&gt;Colleen Hurst&lt;/td&gt;
            &lt;td&gt;Javascript Developer&lt;/td&gt;
            &lt;td&gt;San Francisco&lt;/td&gt;
            &lt;td&gt;39&lt;/td&gt;
          &lt;/tr&gt;
  
        &lt;/tbody&gt;
   &lt;/table&gt;
  </code></pre>
  
  <p><strong>Script :</strong> </p>
  
  <pre><code>  $(document).ready(function() {
    function cbDropdown(column) {
      return $('&lt;ul&gt;', {
        'class': 'cb-dropdown'
      }).appendTo($('&lt;div&gt;', {
        'class': 'cb-dropdown-wrap'
      }).appendTo(column));
    }
  
    $('#example').DataTable({
  
     scrollY: 'calc(100vh - 270px)', //  dictates height of container!
     scrollX: '100%',
  
      initComplete: function() {
        this.api().columns([0, 2]).every(function() {
          var TotChkbxs = 0;
          var TikdChkbxs = 0;
          var column = this;
          var ddmenu = cbDropdown($(column.header()))
  
            .on('change', ':checkbox', function() {
  
              var active;
              var vals = $(':checked', ddmenu).map(function(index, element) {
                active = true;
                return $.fn.dataTable.util.escapeRegex($(element).val());
              }).toArray().join('|');
  
              column
                .search(vals.length &gt; 0 ? '^(' + vals + ')$' : '', true, false)
                .draw();
            });
  
          column.data().unique().sort().each(function(d, j) {
  
            var $label = $('&lt;label&gt;'),
              $text = $('&lt;span&gt;', {
                text: d
              }),
  
              $cb = $('&lt;input&gt;', {
                type: 'checkbox',
                value: d
              });
  
            $text.appendTo($label);
            $cb.appendTo($label);
  
            ddmenu.append($('&lt;li&gt;').append($label));
  
          });
  
        });
  
      }
    });
  
  });
  </code></pre>
  
  <p><strong>CSS :</strong> </p>
  
  <pre><code>.cb-dropdown-wrap {
    max-height: 80px;
    position: relative;
    height: 19px;
  }
  
  .cb-dropdown,
  .cb-dropdown li {
    margin: 0;
    padding: 0;
    list-style: none;
    transition: 0.2s 0.23s height ease-in-out;
  }
  
  .cb-dropdown {
    position: absolute;
    z-index: 1;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background: white;
    border: 1px solid blue;
  }
  
  .active .cb-dropdown {
    background: transparent;
  }
  
  .cb-dropdown-wrap:hover .cb-dropdown {
    /* Expand container */
    height: 200px;
    overflow: auto;
    transition: 0.15s 0.18s height ease-in-out;
  }
  
  .cb-dropdown li.active {
    background: white;
  }
  
  .cb-dropdown li label {
    display: block;
    position: relative;
    cursor: pointer;
    line-height: 20px;
    margin-bottom: 2px;
    border-style: solid;
    border-width: 1px 0px 1px 0px;
    border-color: #dedede;
  }
  
  .cb-dropdown li:last-child {
    padding-bottom: 12px;
  }
  
  .cb-dropdown li label&gt;input {
    position: absolute;
    left: 0;
    top: 1px;
    width: 16px;
  }
  
  .cb-dropdown li label&gt;span {
    display: block;
    margin-left: 25px;
    font-family: sans-serif;
    font-size: 12px;
    font-weight: normal;
    text-align: left;
  }
  
  .cb-dropdown li:nth-child(n+2):hover {
    background: #dedede;
  }
  
  table.dataTable thead .sorting,
  table.dataTable thead .sorting_asc,
  table.dataTable thead .sorting_desc,
  table.dataTable thead .sorting_asc_disabled,
  table.dataTable thead .sorting_desc_disabled {
    background-position: 100% 10px;
  }
  </code></pre>
  
  <p>Fiddle: <a href="https://jsfiddle.net/5djcocuL/" rel="nofollow noreferrer">https://jsfiddle.net/5djcocuL/</a></p>