Tested using version 129.0.6668.59 of Chrome for Windows. Chrome seems to crash every time I try to use subgrid and container queries together.
.comparison-grid {
display: grid;
grid-template-columns: 1fr 1fr;
}
.comparison-item {
container-type: inline-size;
display: grid;
grid-template-rows: subgrid;
}
button {
@container (min-width: 460px) {
position: absolute;
bottom: 2rem;
right: 2rem;
}
}
<div class="comparison-grid">
<div class="comparison-item ">
<p>Item number 1</p>
<button>test</button>
</div>
<div class="comparison-item">
<p>Item number 2</p>
<button>test</button>
</div>
</div>
2
Answers
Ok, there seems to be some issue with
chrome 129
, with layouts and all. Can’t get much information but this layout might be helofulhttps://support.google.com/chrome/thread/297477809/chrome-update-from-128-to-129-causing-application-to-break?hl=en
Though, this shows that subgrid is supported on Chrome 129, but just keep looking out for it.
https://caniuse.com/?search=subgrid
Based on below observations and workarounds, I’m guessing the bug is due to
subgrid
trying to control the layout within ainline-size
/size
container and the container is not letting it, which then crashes the rendering program. Interestingly if we just set the containment of the container toinline-size
without making it ainline-size
query container it won’t crash the page, so there must be something else going on causing this problem when making an element a query container. Hence, it might be better to report an issue with Chromium instead of trying to make them work together.In older Chrome versions such as Chrome 128, though not crashing, the layout within the container simply won’t be affected by the subgrid.
Following this observation, in Chrome 129.0.6668.59 (64bit), you can see that if you add a
layout
containment viacontain
, it will behave like older versions that the subgrid won’t be laying out the child elements within it, and the program won’t crash anymore.One interesting thing is that if you remove
layout
after the size is calculated via JS, both the reflowed result and the container will behave as expected while not crashing the page.Note that this is not intended to be a solution but to demonstrate my observation. If you really need to acheive the same result you proably should consider other layout modules or combining some JS.