Home

Awesome

GridBugs

Inspired by Flexbugs this list aims to be a community curated list of CSS Grid Layout bugs, incomplete implementations and interop issues. Grid shipped into browsers in a highly interoperable state, however there are a few issues - let's document any we find here.

While I'd like to focus on issues relating to the Grid Specification here, it is likely that related specs such as Box Alignment will need to be referenced. If you think you have spotted an issue and it seems to relate to Grid, post it. We can work out the details together and make sure browser or spec issues get logged in the right place.

Also, please raise an issue if I am wrong about any of these or you have more info or examples to add. Quite possibly I've pointed the finger at the wrong UA or missed a change in the spec. Help to make the list accurate appreciated!

This is not CSS Grid technical support

Please raise issues about interop issues where you have already been through the process of creating a Reduced Test Case to check that the issue isn't something in your code. If you want to learn about CSS Grid Layout then check out Grid by Example where I have video tutorials, small examples and links to other resources. I will answer more general grid questions on my AMA when time allows. I also have information regarding fallbacks for older browsers.

The bugs

  1. grid-auto-rows and grid-auto-columns should accept a track listing
  2. Repeat notation should accept a track listing
  3. Fragmentation support
  4. Sizing of items with an intrinsic size inside fixed size grid tracks
  5. Items with an intrinsic aspect ratio should align start
  6. The grid-gap property should accept percentage values
  7. Grid gaps should behave as auto-sized tracks?
  8. Setting max-height to a percentage should scale down a larger image inside a grid track
  9. min-content and max-content in track listings
  10. Some HTML elements can't be grid containers
  11. A textarea that is a grid item collapses to zero width
  12. Space distributed to empty tracks spanned by an item with content
  13. Inconsistency with percentage padding and margins
  14. fit-content is stretching

1. grid-auto-rows and grid-auto-columns should accept a track listing

<table> <tr> <th align="left">Demos</th> <th align="left">Browsers affected</th> <th align="left">Tracking bugs</th> <th align="left">Tests</th> </tr> <tr valign="top"> <td> <a href="https://codepen.io/rachelandrew/pen/Bdoome">1.1</a> &mdash; <em>bug</em> </td> <td> Firefox </td> <td> <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1339672">Firefox #1339672</a> </td> <td><a href="https://github.com/w3c/web-platform-tests/blob/master/css/css-grid-1/implicit-grids/grid-support-grid-auto-columns-rows-002.html">WPT</a></td> </tr> </table>

The properties grid-auto-rows and grid-auto-columns enable an author to set the size of tracks created in the implicit grid. The spec says:

"If multiple track sizes are given, the pattern is repeated as necessary to find the size of the implicit tracks. The first implicit grid track before the explicit grid receives the first specified size, and so on forwards; and the last implicit grid track before the explicit grid receives the last specified size, and so on backwards." - 7.6 Implicit Track Sizing

2. Repeat notation should accept a track listing

<table> <tr> <th align="left">Demos</th> <th align="left">Browsers affected</th> <th align="left">Tracking bugs</th> </tr> <tr valign="top"> <td> <a href="https://codepen.io/rachelandrew/pen/prjjLy">2.1</a> &mdash; <em>bug</em> </td> <td> Firefox </td> <td> <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1341507">Firefox #1341507</a> </td> </tr> </table>

Repeat notation can accept a single track sizing to repeat, eg:

repeat(3,200px);

Or a track listing:

repeat(3, 200px 100px);

This includes when the number of repeats is auto-fill or auto-fit to create as many tracks as will fit.

"The first argument specifies the number of repetitions. The second argument is a track list, which is repeated that number of times." - Syntac of repeat()

3. Fragmentation Support

<table> <tr> <th align="left">Demos</th> <th align="left">Browsers affected</th> <th align="left">Tracking bugs</th> </tr> <tr valign="top"> <td></td> <td> Firefox <br>Chrome <br>Safari </td> <td> <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1266265">Firefox #1266265</a><br> <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=614667">Chrome #614667</a></td> </tr> </table>

There is limited fragmentation support across browsers at present, therefore features such as the break-* properties are unlikely to work reliably. For details of how fragmentation should work in Grid Layout see 12. Fragmenting Grid Layout.

4. Sizing of items with an intrinsic size inside fixed size tracks

<table> <tr> <th align="left">Demos</th> <th align="left">Browsers affected</th> <th align="left">Tracking bugs</th> </tr> <tr valign="top"> <td> <a href="https://codepen.io/rachelandrew/pen/eEpeXW/">4.1</a> &mdash; <em>bug</em> </td> <td> Firefox </td> <td> <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1385410">Firefox #1385410</a> </td> </tr> </table>

In Firefox images with an intrinsic size are scaling down to fit into a fixed size grid track, rather than overflowing.

I believe that the correct behavior is to overflow, as per the CSS WG resolution of Issue 523.

5. Items with an intrinsic aspect ratio should align start

<table> <tr> <th align="left">Demos</th> <th align="left">Browsers affected</th> <th align="left">Tracking bugs</th> </tr> <tr valign="top"> <td> <a href="https://codepen.io/rachelandrew/pen/LjprNE">5.1</a> &mdash; <em>bug</em><br> <a href="https://codepen.io/rachelandrew/pen/prjQRz">5.2</a> &mdash; <em>workaround</em> </td> <td> Safari 10 (fixed in Technical Preview) </td> <td></td> </tr> </table>

In Safari 10, a grid item that has an intrinsic aspect ratio was defaulting to stretch, rather than start.

Workaround

The workaround for this is to declare align-self: start and justify-self: start on the item.

6. The grid-gap property should accept percentage values

<table> <tr> <th align="left">Demos</th> <th align="left">Browsers affected</th> <th align="left">Tracking bugs</th> </tr> <tr valign="top"> <td> <a href="https://codepen.io/rachelandrew/pen/QMjPXq">6.1</a> &mdash; <em>bug</em> </td> <td> Safari 10 (fixed in <a href="https://developer.apple.com/safari/technology-preview/release-notes/#r29">Technical Preview 29</a>) </td> <td> <a href="https://bugs.webkit.org/show_bug.cgi?id=170764">WebKit #170764</a> </td> </tr> </table>

Currently percentage values of grid-gap are marked as at-risk in the Level 1 specification. A strong use case for percentage values is that of adding some grid layout features to a layout which already uses a float, or flexbox-based grid system see tweet from @minamarkham. These systems have to use percentages for spacing in order to create a 'grid'.

7. Grid gaps should behave as auto-sized tracks?

There is also an interop issue with regard to percentage grid-row-gap values, where the height of the grid is not a fixed size. Chrome and Safari TP, plus Edge Preview collapse the row gap to 0. Firefox is using a percentage of the total height, I think.

8. Setting max-height to a percentage should scale down a larger image inside a grid track

<table> <tr> <th align="left">Demos</th> <th align="left">Browsers affected</th> <th align="left">Tracking bugs</th> </tr> <tr valign="top"> <td> <a href="https://codepen.io/rachelandrew/pen/YxqVNz">8.1</a> &mdash; <em>bug</em> </td> <td> Chrome </td> <td> <a href="https://bugs.chromium.org/p/chromium/issues/detail?id=750631">Chromium #750631</a> </td> </tr> </table>

Using max-height on an image inside a fixed size track should resolve so that the image scales down to fit inside the track. Currently in Chrome this does not work and so the image overflows. Using max-width works when the image is constrained by the column track sizing, setting a fixed height works as expected as does setting a max-height using a length unit such as px.

9. min-content and max-content in track listings

<table> <tr> <th align="left">Demos</th> <th align="left">Browsers affected</th> <th align="left">Tracking bugs</th> </tr> <tr valign="top"> <td> <a href="https://codepen.io/rachelandrew/pen/eEzbpN">9.1</a> &mdash; <em>bug</em> </td> <td> Safari 10 (fixed in Technology Preview) </td> <td><a href="https://bugs.webkit.org/show_bug.cgi?id=169195">WebKit #169195</a></td> </tr> </table>

In Safari 10, the values min-content, max-content and fit-content were prefixed. These have now been unprefixed in Safari Technology Preview.

Workaround

The workaround for this is to use the prefixed -webkit-min-content, -webkit-max-content and -webkit-fit-content.

10. Some HTML elements can't be grid containers

<table> <tr> <th align="left">Demos</th> <th align="left">Browsers affected</th> <th align="left">Tracking bugs</th> </tr> <tr valign="top"> <td> <a href="https://codepen.io/rachelandrew/pen/dzXwRJ">10.1</a> &mdash; <em>bug (fieldset)</em><br> <a href="https://codepen.io/rachelandrew/pen/dzXwRJ">10.2</a> &mdash; <em>bug (button)</em> </td> <td> Chrome<br> Safari 10 (fieldset fixed in Technology Preview) </td> <td><a href="https://bugs.chromium.org/p/chromium/issues/detail?id=375693">Chromium #375693</a></td> </tr> </table>

In Chrome (and Safari 10) fieldset elements with display: grid do not act as grid containers. The button element only functions as a grid container in Firefox. This is related to the same issue in Flexbox, detailed on the Flexbugs site.

11. A textarea that is a grid item collapses to zero width

<table> <tr> <th align="left">Demos</th> <th align="left">Browsers affected</th> <th align="left">Tracking bugs</th> </tr> <tr valign="top"> <td> <a href="https://yuheiy.github.io/pub/textarea-in-grid.html">11.1</a> &mdash; <em>bug</em> </td> <td> Chrome (on OSX only) </td> <td><a href=" https://bugs.chromium.org/p/chromium/issues/detail?id=727076">Chromium #727076</a></td> </tr> </table>

On OS X Chrome, if a textarea is a grid item it collapses to 0 width when text is typed into it. Linked to test case from the Chromium issue as due to the way CodePen loads into an iframe this doesn't seem to happen there.

12. Space distributed to empty tracks spanned by an item with content

<table> <tr> <th align="left">Demos</th> <th align="left">Browsers affected</th> <th align="left">Tracking bugs</th> </tr> <tr valign="top"> <td> <a href="https://codepen.io/rachelandrew/pen/vJXJQr">12.1</a> &mdash; <em>bug 1</em><br> <a href="https://codepen.io/rachelandrew/pen/aymLmq">12.2</a> &mdash; <em>bug 2</em> </td> <td> Firefox </td> <td><a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1386921">Firefox #1386921</a><br> <a href="https://bugzilla.mozilla.org/show_bug.cgi?id=1386932">Firefox #1386932</a></td> </tr> </table>

If you have a grid with empty tracks which are spanned by an item on the grid, those tracks should not be assigned extra space due to the spanning item. Firefox is assigning extra space (bug 1), related is the fact that Firefox does different things depending on source order (bug 2).

Thanks to everyone who helped to isolate these issues here. The discussion is useful if you want to understand exactly what is going on.

13. Inconsistency with percentage padding and margins

<table> <tr> <th align="left">Demos</th> <th align="left">Browsers affected</th> <th align="left">Tracking bugs</th> </tr> <tr valign="top"> <td> <a href="https://codepen.io/rachelandrew/pen/brYXNQ">13.1 &mdash; <em>bug</em></a> </td> <td> Firefox &amp; Edge match<br> Chrome &amp Webkit match </td> <td><href="https://bugs.chromium.org/p/chromium/issues/detail?id=229568">Chrome #229568</a></td> </tr> </table>

As detailed by @mrego there is a longstanding interoperability issue with percentage padding and margins in both Grid and Flexbox.

Firefox and Edge (Preview) resolve the percentage margins/paddings on items against their respective dimension (width or height), Chrome always uses width, in the same way that percentages are resolved in block layout. The specification allows for both possibilities, and suggests authors do not use percentage margins and padding.

14. fit-content is stretching

<table> <tr> <th align="left">Demos</th> <th align="left">Browsers affected</th> <th align="left">Tracking bugs</th> <th align="left">Tests</th> </tr> <tr valign="top"> <td> <a href="https://codepen.io/rachelandrew/pen/WEXBMR">14.1 &mdash; <em>bug</em></a> </td> <td> Chrome<br> Webkit </td> <td><a href="https://bugs.chromium.org/p/chromium/issues/detail?id=755994">Chrome #755994</a><br> <a href="https://github.com/w3c/csswg-drafts/issues/1732">CSS Spec issue #1732</a></td> <td><a href="https://github.com/w3c/web-platform-tests/blob/master/css/css-grid-1/alignment/grid-fit-content-tracks-dont-stretch-001.html">WPT</a></td> </tr> </table>

Report by @simevidas Chrome is stretched tracks sized with fit-content where Firefox does not. Edge (Preview) matches the behaviour in Firefox.

It turned out this is less straightforward than first appeared. See the discussion on the issue raised against the CSS spec. During the telecon on September 20, 2017 the CSS WG resolved that tracks should not stretch, making the Firefox/Edge behaviour correct. The next day a patch was submitted to Blink to fix the issue in Chrome.

Workaround

The workaround for this is to use justify-content: start or justify-content: end on the tracks.

Acknowledgments

Gridbugs is maintained by @rachelandrew and was heavily inspired by the excellent Flexbugs.

Contributing

In the first instance raise an Issue, include a Reduced Test Case that demonstrates the problem clearly. If you are aware of a workaround for the problem, add that too.