<!DOCTYPE html>
<html>
    <head>
        <script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
        <link href="//cdn.datatables.net/1.10.2/css/jquery.dataTables.css" rel="stylesheet" type="text/css" />
        <link href="//cdn.datatables.net/colvis/1.1.1/css/dataTables.colVis.css" rel="stylesheet" type="text/css" />
        <link href="//cdn.datatables.net/fixedcolumns/3.0.2/css/dataTables.fixedColumns.css" type="text/css" />
        <script src="//cdn.datatables.net/1.10.2/js/jquery.dataTables.js"></script>
        <script src="//cdn.datatables.net/colvis/1.1.1/js/dataTables.colVis.js"></script>       
        <script src="//cdn.datatables.net/fixedcolumns/3.0.2/js/dataTables.fixedColumns.js"></script>       
        
        <meta charset=utf-8 />
        <title>DataTables - JS Bin</title>
    </head>
    <body>
        <div class="container">
            <!-- <table id="example" class="display" width="100%"> -->
            <table id="example" class="display">
                <thead>
                    <tr>
                        <th style="width:100px">Name</th>
                        <th style="width:100px">Position</th>
                        <th style="width:100px">Office</th>
                        <th style="width:100px">Age</th>
                        <th style="width:100px">Start date</th>
                        <th style="width:100px">Salary</th>
                        <th style="width:100px">Name</th>
                        <th style="width:100px">Position</th>
                        <th style="width:100px">Office</th>
                        <th style="width:100px">Age</th>
                        <th style="width:100px">Start date</th>
                        <th style="width:100px">Salary</th>
                    </tr>
                </thead>
                <tbody>
                    <tr>
                        <td>Tiger Nixon</td>
                        <td>System Architect</td>
                        <td>Edinburgh</td>
                        <td>61</td>
                        <td>2011/04/25</td>
                        <td>$3,120</td>
                        <td>Tiger Nixon</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>Garrett Winters</td>
                        <td>Director</td>
                        <td>Edinburgh</td>
                        <td>63</td>
                        <td>2011/07/25</td>
                        <td>$5,300</td>
                        <td>Garrett Winters</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>Ashton Cox</td>
                        <td>Technical Author</td>
                        <td>San Francisco</td>
                        <td>66</td>
                        <td>2009/01/12</td>
                        <td>$4,800</td>
                        <td>Ashton Cox</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>Cedric Kelly</td>
                        <td>Javascript Developer</td>
                        <td>Edinburgh</td>
                        <td>22</td>
                        <td>2012/03/29</td>
                        <td>$3,600</td>
                        <td>Cedric Kelly</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>Jenna Elliott</td>
                        <td>Financial Controller</td>
                        <td>Edinburgh</td>
                        <td>33</td>
                        <td>2008/11/28</td>
                        <td>$5,300</td>
                        <td>Jenna Elliott</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>Brielle Williamson</td>
                        <td>Integration Specialist</td>
                        <td>New York</td>
                        <td>61</td>
                        <td>2012/12/02</td>
                        <td>$4,525</td>
                        <td>Brielle Williamson</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>Herrod Chandler</td>
                        <td>Sales Assistant</td>
                        <td>San Francisco</td>
                        <td>59</td>
                        <td>2012/08/06</td>
                        <td>$4,080</td>
                        <td>Herrod Chandler</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>Rhona Davidson</td>
                        <td>Integration Specialist</td>
                        <td>Edinburgh</td>
                        <td>55</td>
                        <td>2010/10/14</td>
                        <td>$6,730</td>
                        <td>Rhona Davidson</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>Colleen Hurst</td>
                        <td>Javascript Developer</td>
                        <td>San Francisco</td>
                        <td>39</td>
                        <td>2009/09/15</td>
                        <td>$5,000</td>
                        <td>Colleen Hurst</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                    <tr>
                        <td>Sonya Frost</td>
                        <td>Software Engineer</td>
                        <td>Edinburgh</td>
                        <td>23</td>
                        <td>2008/12/13</td>
                        <td>$3,600</td>
                        <td>Sonya Frost</td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                        <td></td>
                    </tr>
                </tbody>
            </table>
        </div>
    </body>
</html>
 
body {
    font: 90%/1.45em "Helvetica Neue", HelveticaNeue, Verdana, Arial, Helvetica, sans-serif;
    margin: 0;
    padding: 0;
    color: #333;
    background-color: #fff;
}
div.container {
    margin: 0 auto;
}
table.dataTable {
  width: auto;
  margin: 0;
  table-layout: fixed;
  word-wrap:break-word;
}
 
$(document).ready( function () {
  var table = $('#example').DataTable({
    "dom": 'C<"clear">ti',
    "ordering" : false, 
    "searching" : false,
    "scrollY": "600px",
    "scrollX": true,
    "scrollCollapse": true,
    //"autoWidth": true,
    "paging": false,
    "colVis": {
      "exclude": [ 0 ],
      "overlayFade": 50
    }
  });
  new $.fn.dataTable.FixedColumns(table);
} );
Output 300px

This bin was created anonymously and its free preview time has expired. Get a free unrestricted account

Dismiss x
public
Bin info
anonymouspro
0viewers