diff --git a/src/css/layui.css b/src/css/layui.css index e6b31ab6..e8fd6c54 100644 --- a/src/css/layui.css +++ b/src/css/layui.css @@ -840,7 +840,6 @@ a cite{font-style: normal; *cursor:pointer;} .layui-table-hover, .layui-table-click{background-color: #FAFAFA;} -.layui-table[lay-even] tr:nth-child(even){background-color: #f2f2f2;} .layui-table th, .layui-table td, @@ -937,6 +936,7 @@ a cite{font-style: normal; *cursor:pointer;} .layui-table-body{position: relative; overflow: auto; margin-right: -1px; margin-bottom: -1px;} .layui-table-body .layui-none{line-height: 26px; padding: 30px 15px; text-align: center; color: #999;} +.layui-table-body .layui-table[lay-even] tr:nth-child(even){background-color: #f2f2f2;} .layui-table-fixed{position: absolute; left: 0; top: 0; z-index: 101;} .layui-table-fixed .layui-table-body{overflow: hidden;} .layui-table-fixed-l{box-shadow: 1px 0 8px rgba(0,0,0,.08);} diff --git a/src/modules/table.js b/src/modules/table.js index 25cd0f60..1a710d6e 100644 --- a/src/modules/table.js +++ b/src/modules/table.js @@ -790,7 +790,14 @@ layui.define(['laytpl', 'laypage', 'form', 'util'], function(exports){ } that.setGroupWidth(); - + + // 如果表格内容为空(无数据 或 请求异常) + if (that.layMain.find('tbody').is(":empty")) { + // 将表格宽度设置为跟表头一样的宽度,使之可以出现底部滚动条,以便滚动查看所有字段 + const headerWidth = that.layHeader.first().children('table').width() + that.layMain.find('table').width(headerWidth); + } + that.loading(!0); };