表格固定列固定表頭插件結合css3


/*20170628固定表格列*/
;(function($){
$.fn.Scrollhanle=function(set){
var opt=$.extend({
size:3
},set||{});
return this.each(function(){
var sleft=$(this);
var $color='#FFF';
var $headtr=sleft.find('thead>tr');
var $tbody=sleft.find('tbody tr');
sleft.scroll(function(){
var scrollTopval=sleft.scrollTop();
var scrollLeftval=sleft.scrollLeft();
$headtr.css('background',$color)[0].style.transform='translateY('+scrollTopval+'px)';
if(scrollLeftval>=0){
$tbody.each(function(e){
$color2=$(this).css('background-color');
$(this).children('td').slice(0,opt.size).each(function(index){
$headtr.children('th').eq(index).css('background',$color)[0].style.transform='translateX('+scrollLeftval+'px)';
$(this).css('background',$color2)[0].style.transform='translateX('+scrollLeftval+'px)';
})
})
}
})

})

}
})(jQuery)
 

  


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM