当前位置 博文首页 > 你是人间四月天:layui 左侧表格与右侧边浮动栏高度对齐

    你是人间四月天:layui 左侧表格与右侧边浮动栏高度对齐

    作者:[db:作者] 时间:2021-09-05 13:11

    在这里插入图片描述
    在这里插入图片描述

    .layui-table-cell, .layui-table-col-special {
    			height: auto;
    		}
    

    在done中调用

    done: function(data) {
    		autoFixed($(this.elem[0]).next())
    	}
    
    	/**
         * 根据表格宽度自动显示右侧浮动栏,并修正浮动栏高度
         * @param tableElem 绑定元素的dom
         */
        function autoFixed(tableElem) {
            var $tableView = tableElem || $(".layui-table-view");
            var dataIndex, trHeight;
            $tableView.each(function () {
                // 获取两侧浮动栏
                var $fixed = $(this).find(".layui-table-fixed");
                // 同步表头高度
                $fixed.find(".layui-table-header tr").height($(this).find(".layui-table-header tr").eq(0).height());
                // 遍历tr 修正浮动栏行高
                $(this).find(".layui-table-main tr").each(function () {
                    dataIndex = $(this).attr("data-index");
                    trHeight = $(this).css("height");
                    $fixed.find("tr[data-index=" + dataIndex + "]").css("height", trHeight);
                })
            });
        }
    
    cs