CSS Grid Layout in Chrome seems not to work properly with more than 1000 rows

前端 未结 2 1418
终归单人心
终归单人心 2020-12-31 10:45

I have created an example of a sliding grid with fixed headers, using the \"CSS Grid Layout\" and \"sticky position\" technologies. For convenience, the content of the grid

相关标签:
2条回答
  • I've made a pen that implements a possible workaround to this issue: 10K Rows CSS Grid Table

    In short - the solution is to only render the visible rows based on the scroll position. The non-visible rows should be replaced with a single "gap-filling" row that receives their total height.

    To make it "optimistic", that gap-filling row should also receive a gradient background that simulates the horizontal row lines to make it look as if the lines are there (since this row will be briefly visible as the user scrolls and we don't want it to be blank).

    In terms of performance, a table of 100 rows will perform exactly the same as a table with 10K rows when applying this solution.

    For example:

    <div class="table">
      <div class="gap-before" 
           style="height: {{total height of rows before the visible rows}}">
      <!-- visible rows go here -->
      <div class="gap-after" 
           style="height: {{total height of rows after the visible rows}}">
    </div>
    
    0 讨论(0)
  • 2020-12-31 11:23

    Ok, the 1000 rows (and also 1000 columns) limit has been intentionally introduced into the Chrome engine for reasons of stability and RAM consumption. A new version of the Grid functionality seems to be in progress and should solve the problem.

    Sources:

    • https://bugs.chromium.org/p/chromium/issues/detail?id=688640
    • https://github.com/w3c/csswg-drafts/issues/1009
    0 讨论(0)
提交回复
热议问题