css列名不动_table.js(table表头不动,身体滚动)

(function($){

$.chromatable = {

defaults: {

width:'100%',

height:'165px',

scrolling: "yes"

}

};

$.fn.chromatable = function(options){

var options = $.extend({}, $.chromatable.defaults, options);

return this.each(function(){

var $this = $(this);

var $uniqueID = $(this).attr("ID") + ("wrapper");

$(this).css('width', options.width).addClass("_scrolling");

$(this).wrap('

$(".scrolling_outer").css({'position':'relative'});

$("#"+$uniqueID).css({

'width' : '100%',

'overflow-x':'hidden',

'overflow-y':'auto',

'color':"#666666",

});

$("#"+$uniqueID).css('height', options.height);

$("#"+$uniqueID).css('width', options.width);

$(this).before($(this).clone().attr("id", "").addClass("_thead").css({

'width' : '100%',

'background':'#F5F5F5',

'display' : 'block',

'position':'absolute',

'border':'none',

'top':'0px'

}));

$('._thead').children('tbody').remove();

$(this).each(function( $this ){

if (options.width == "100%" || options.width == "auto") {

$("#"+$uniqueID).css({'padding-right':'0px'});

}

if (options.scrolling == "no") {

$("#"+$uniqueID).before('Expand table');

$("#"+$uniqueID).css({'padding-right':'0px'});

$(".expander").each(

function(int){

$(this).attr("ID", int);

$( this ).bind ("click",function(){

$("#"+$uniqueID).css({'height':'auto'});

$("#"+$uniqueID+" ._thead").remove();

$(this).remove();

});

});

$("#"+$uniqueID).resizable({ handles: 's' }).css("overflow-y", "hidden");

}

});

$curr = $this.prev();

$("thead:eq(0)>tr th",this).each( function (i) {

$("thead:eq(0)>tr th:eq("+i+")", $curr).width( $(this).width());

});

if (options.width == "100%" || "auto"){

$(window).resize(function(){

resizer($this);

});

}

});

};

function resizer($this) {

$curr = $this.prev();

$("thead:eq(0)>tr th", $this).each( function (i) {

$("thead:eq(0)>tr th:eq("+i+")", $curr).width( $(this).width());

});

};

})(jQuery);

表头

每一行内容

$("#plus-table").chromatable({

width: '100%',

height: "165px",

scrolling: "yes"

});

$("#reduce-table").chromatable({

width: '100%',

height: "165px",

scrolling: "yes"

});

$("#sum-table").chromatable({

width: '100%',

height: "165px",

scrolling: "yes"

});

下面是将这些代码改为xlwt支持的格式的示例: ```python import xlwt # 创建一个工作簿 workbook = xlwt.Workbook(encoding='utf-8') # 创建一个格式,用于设置表头 format_title = xlwt.easyxf('font: bold on; align: horiz center, vert center; pattern: pattern solid, fore_colour gray25; font: name Arial, height 200;') # 创建一个格式,用于设置表格中的数据 format_table_headers = xlwt.easyxf('align: horiz center, vert center; pattern: pattern solid, fore_colour gray25; font: name Arial, height 200; borders: top thin, bottom thin, left thin, right thin;') # 创建一个工作表 sheet = workbook.add_sheet('Sheet1') # 设置表头 sheet.write(0, 0, '节点ID', format_title) sheet.write(0, 1, '节点名称', format_title) sheet.write(0, 2, '节点类型', format_title) # 添加数据 sheet.write(1, 0, 1, format_table_headers) sheet.write(1, 1, '节点1', format_table_headers) sheet.write(1, 2, '类型A', format_table_headers) sheet.write(2, 0, 2, format_table_headers) sheet.write(2, 1, '节点2', format_table_headers) sheet.write(2, 2, '类型B', format_table_headers) sheet.write(3, 0, 3, format_table_headers) sheet.write(3, 1, '节点3', format_table_headers) sheet.write(3, 2, '类型C', format_table_headers) # 保存工作簿 workbook.save('node.xls') ``` 注意,xlwt中的样式参数是通过easyxf方法传递的,可以使用类似CSS样式的语法来设置样式参数。例如,'font: bold on'表示字体加粗,'align: horiz center, vert center'表示水平和垂直居中对齐,'pattern: pattern solid, fore_colour gray25'表示设置背景颜色为灰色,'borders: top thin, bottom thin, left thin, right thin'表示设置边框为细线。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值