Skip to content

Instantly share code, notes, and snippets.

@sakadonohito
Created August 25, 2013 02:43
Show Gist options
  • Select an option

  • Save sakadonohito/6331657 to your computer and use it in GitHub Desktop.

Select an option

Save sakadonohito/6331657 to your computer and use it in GitHub Desktop.
ヘッダ固定でボディだけスクロールさせる
$(function(){
function table_adjust(){
var width_arr = new Array();
var tbody_tds = $('#estimateList tbody tr:first-child td');
var thead_ths = $('#estimateList thead tr:first-child th');
$.each($(tbody_tds),function(i){
width_arr.push($(this).width());
});
$.each($(thead_ths),function(i){
$(this).width(width_arr[i]);
});
}
$(document).ready(function(){
table_adjust();
});
$(window).resize(function(){
table_adjust();
});
});
#list-box{
height: 380px;
padding-top: 80px;
position: relative;
float: none;
}
.scroll {
overflow-x: auto;
overflow-y: auto;
height: 380px;
}
#list-box thead {
clear: both;
float: none;
position: absolute;
top: 0px;
left: 0px;
height: 80px;
overflow-x: auto;
overflow-y: hidden;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment