layui多级表头,行高,序号,fixed固定对不齐问题

浪淘沙2天前前端4
<style>
            /* 表头文字垂直居中 */
            .layui-tablethead th .layui-table-cell,.layui-table-fixed-l.layui-table-header th .layui-table-cell,
            .layui-table-fixed-r .layui-table-header th .layui-table-cell 
            {  
                line-height: 25px !important; /* 控制表头文字居中 */
              text-align: center;                
              vertical-align: middle;                
              white-space: nowrap; /* 可改 normal 允许换行 */
            }
</style>
  ,lineStyle: 'height: 50px;'
  ,cols: [[
          { type: 'checkbox', fixed: 'left', rowspan: 2 },
          { type: 'numbers', title: '序号', width: 60, rowspan: 2 },
          { title: '<span style="color:#f00">省厅导入</span>', align: 'center', colspan: 3 },
                    { title: '<span style="color:#f00">一生一档</span>', align: 'center', colspan: 3 },    
          ],
          [
             { field: 'kdslb', title: '困难生类别', minWidth: 140, rowspan: 2 }
            ,{ field: 'byqx', title: '毕业去向', minWidth: 150 }
            ,{ field: 'yrdw', title: '用人单位', minWidth: 180 }
            ,{ field: 'sfkds', title: '困难生', minWidth: 120 }
            ,{ field: 'yjjysj', title: '预计就业时间', minWidth: 200 }
            ,{ field: 'jyyx', title: '就业意向', minWidth: 150, rowspan: 2 }
           ]]
           
      ,done: function (res, curr, count) {

      $(".layui-table-header tr").each(function(index){
          $(this).css("height","25px");
      });
      $(".layui-table-header th .layui-table-cell").css("line-height","25px");      // 2️⃣ 同步左右 fixed 表头
      $(".layui-table-fixed-l .layui-table-header tr").each(function(index){          var h = $(".layui-table-header tr").eq(index).outerHeight();
          $(this).css("height", h);
          $(this).find("th .layui-table-cell").css("line-height", h + "px");
      });
      $(".layui-table-fixed-r .layui-table-header tr").each(function(index){          var h = $(".layui-table-header tr").eq(index).outerHeight();
          $(this).css("height", h);
          $(this).find("th .layui-table-cell").css("line-height", h + "px");
      });      // 3️⃣ 同步内容行固定50px(可选,通常 lineStyle 已控制)
      $(".layui-table-main tr").each(function(index){          var h = $(this).outerHeight();
          $(".layui-table-fixed-l .layui-table-body tr").eq(index).css("height", h);
          $(".layui-table-fixed-r .layui-table-body tr").eq(index).css("height", h);
      });      // 渲染完成后更新 URL
      var url = new URL(window.location);
      url.searchParams.set('pageindex', curr);
      window.history.pushState({}, '', url);

                   
 }

image.png

相关文章

layui 下拉搜索,多选,form提交

https://codecp.tech/static/xm-select/?lalalalalala=1#/basic/use<div style="margin:100px...

echarts获取点击事件,详细参数

myChart.on('click', (params) => {    console.log(`你点击了系列 ${params.name}`); ...

layui提交时,弹出一个确认对话框

<form class="layui-form" method="post" id="myForm"&g...

删除确认对话框

onclick=\"onconfirm('确认要删除本岗位?', 'zp', 'id=&act=del');&nb...

layui 复制图片和文字到内存,以转发到微信,qq,钉钉

   , { field: 'id', title: '活动二维码', wid...

发表评论    

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。