将心比心,方得人心~

layui 设置表格高度自适应后,工具栏设置fixed后高度,不一致问题

周洲 2022-02-28 13:35:53

方案1:

js部分:
done: function () {
	//设置工具栏表头高度
    $(".layui-table-header").eq(1).find("table").height($(".layui-table-header").eq(0).height()+1);
    //设置工具栏按钮栏高度
    $(".layui-table").eq(1).find("tr").each(function(index,ele){
    	$(".layui-table-body").eq(1).find("tr").eq(index).height($(ele).height());
    });
}
css部分:
    .layui-table-cell {
        height: auto !important;
    }


方案二(推荐):

 js部分:                
,done: function(res, curr, count){
                        // 该方法用于解决,使用fixed固定列后,行高和其他列不一致的问题
                        $(".layui-table-main  tr").each(function (index, val) {
                            $($(".layui-table-fixed .layui-table-body tbody tr")[index]).height($(val).height());
                        });
                    }
css部分:
    .layui-table-cell {
        height: auto !important;
    }



打赏

『微信打赏』

Tag标签layui 

我是有底线的