html - Table Header with fixed header without using div -


i want table header fixed width without using div tag outside table. need solution in need change css file only. have tried putting table in side div style:

width:100%;overflow-x:scroll 

and on minimizing browser's height , width, working fine.

but not want. want change in css style only, avoid change in jsp files in project

psb code:

css

h3 {     font: bold 1.2em verdana, helvetica, arial, sans-serif;     background: #b7bbd6;     padding: 5px;     margin: 10px 0 0 0;     clear: both; } .list {     float: left;     width: 100%;     color: #000099;     border: 1px solid #dedfde;     margin: 0 0 15px 0;     overflow-x: scroll } .list th, .list td {     vertical-align: top;     border: 1px solid #b7bbd6 } .even {     background: #f1f1f1 } /*.odd {background: #f1f1f1}*/ .odd {     background: #fff } 

html

<h3>test table</h3>  <table class="list">         <tr>             <th>a</th>             <th>b</th>             <th>c</th>             <th>d</th>             <th>e</th>             <th>f</th>             <th>g</th>             <th>h</th>             <th>i</th>         </tr>         <tr class="odd">             <td>98052826</a></td>             <td>company</td>             <td>asdfsafdsa</td>             <td>asdfsadf</td>             <td>asdfsafs</td>             <td>sadfsaf</td>             <td>1234</td>             <td>asfsdf</td>             <td>asfsafdf</td>         </tr>         <tr class="even">             <td>234568992</a></td>             <td>private</td>             <td>asfsdfaf</td>             <td>asfsaf</td>             <td>safsdafsdf</td>             <td>some address</td>             <td>3344</td>             <td>&safsdafsda</td>             <td>sadfsaddfdaf</td>         </tr> <table> 

please suggest??

set following css stylesheet:

table{width: 100%;table-layout: fixed;} 

edit

if use jquery, easy:

$(document).ready(function(){ /*define table class place class here instead of 'table'*/    var tablewidth =  $('table').width();    /*define h3 class place class here instead of 'h3'*/     $('h3').css('width',tablewidth - 10); }); 

demo


Comments

Popular posts from this blog

matlab - Deleting rows with specific rules -

php - MySQLi multi_query results for later use -