Correct implementation of CSS Grid in Firefox and Chrome

最后都变了- 提交于 2019-12-11 10:57:13

问题


As concluded here, CSS Grid implement equal height elements across rows by using grid-auto-rows: 1fr. However, Chrome and Firefox manifest different behaviours when inserting rows with a height set to auto between the equal height rows. That is, Chrome achieves equal height across rows when using the explicit grid-auto-rows: auto 1fr 1fr 1fr syntax but only equal height on a per row basis when using repeat like grid-auto-rows: auto repeat(3, 1fr); while Firefox only achieves equal height on a per row basis regardless.

Please observe the following in both Firefox and Chrome:

https://codepen.io/Hlsg/pen/eemRmm

https://codepen.io/Hlsg/pen/jGWQwM

Interestingly, they both behave the same with this implementation, so I'm thinking this is more to do with their implementation of css repeat:

https://codepen.io/Hlsg/pen/VWKPzq

What's your take on this, and which browser do you think has the correct, standard aproach?


回答1:


Interestingly, they both behave the same with this implementation, so I'm thinking this is more to do with their implementation of css repeat.

I think you're correct.

If you look at the spec definition for grid-auto-rows and grid-auto-columns, the repeat() notation does not appear to be an acceptable value.

The definition says that only track sizes are acceptable values. And the definition of "track size" does not include repeat().

So a violation of the spec or, at a minimum, unclear spec language, may lead to differing browser implementations.

https://www.w3.org/TR/css3-grid-layout/#auto-tracks



来源:https://stackoverflow.com/questions/47013688/correct-implementation-of-css-grid-in-firefox-and-chrome

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!