Skip to content

[css-grid-2] Aspect ratio and the row axis #12964

Open

Description

@alisonmaher

In the following test case:

<p>Test passes if there is a filled green square.</p>
<div style="display: inline-grid; background: green; aspect-ratio: 1/1; min-height: 60px; grid-template-rows: repeat(auto-fill, 50px);"></div>

All browsers appear to render a 60x60 green square, as opposed to 100x100. In order to hit the min-height, though, you'd expect to produce 2 50px rows.

Image

In the column direction, however, this works as expected, and 2 50px columns are produced, resulting in a 100x100 square:

<p>Test passes if there is a filled green square.</p>
<div style="display: inline-grid; background: green; aspect-ratio: 1/1; min-height: 60px; grid-template-columns: repeat(auto-fill, 50px);"></div>
Image

Is this expected to only work in the column direction? (Same question applies for masonry)

Activity

  1. added
    css-grid-2
    on Oct 16, 2025
  2. moved this to FTF agenda items in CSSWG January 2026 meetingon Jan 22, 2026
  3. tabatkins commented on Jan 23, 2026

    @tabatkins
    Member

    This just looks like an impl bug. The spec is clear, and we should def be consistent between rows and columns. I suspect someone early on just wrote a buggy test, and everyone followed the test instead of the spec?

  4. Loirooriol commented on Jan 23, 2026

    @Loirooriol
    Contributor

    I don't think it's because of a buggy test.

    It's because, in the 2nd case, when computing the min/max-content inline sizes you transfer size constraints from the block axis thru the aspect ratio. So (roughly speaking) min-height: 60px gets transferred into min-width: 60px. And this results in a width of 100px:

    <div style="display: inline-grid; background: green; height: 10px; min-width: 60px; grid-template-columns: repeat(auto-fill, 50px);"></div>

    In the first case, though, you first compute the min/max-content inline sizes. And you don't want to perform layout when doing so, so you just transfer min-height: 60px, even if grid layout would end up producing a height of 100px. And this results in a width of 60px:

    <div style="display: inline-grid; background: green; height: 10px; min-width: 60px; grid-template-rows: repeat(auto-fill, 50px);"></div>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Needs Testcase (WPT)css-grid-2

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

    Sponsor
    SponsoredKunjungi sekarang
    Promo