我正在尝试使用滚动条创建一个大型HTML表(大约5000行),所以我考虑将该表插入一个<div>我可以随后格式化的表格.
它在Firefox 47和IE 11中运行良好,但在Chrome 59中滚动时表现不佳.
<!DOCTYPE html>
<html>
<head>
<title>Test page</title>
</head>
<body>
<div style="width: 400px; height: 300px; overflow: scroll;" id="test"></div>
<script>
let table = '<table style="table-layout: fixed; width: 3000px">';
table += '<thead>';
table += '<tr>';
for(let i=0; i < 30; i++) {
table += '<th style="width: 100px">#' + i +'</th>';
}
table += '</tr>';
table += '</thead>';
table += '<tbody>';
for(let i=0; i < 5000; i++) {
table += '<tr>';
for(let j=0; j < 30; j++) …Run Code Online (Sandbox Code Playgroud)