CSS Flex, Grid, and Containing Blocks
blog.duvallj.pw·29w
Preview
Report Post

TL;DR: Changing from display: flex; to display: grid; can break certain designs due to differences in how containing blocks work between them. If you read that and went “what does that even mean??”, keep reading.

The Bug

This toy example is based on a real bug that completely slipped under my radar in code review, so I am highly motivated to write this blog post & understand in meticulous detail exactly what’s going on with it:

<style>
.Container {
border: solid black 2px;
padding: 8px;
contain: strict;
height: 200px;
display: flex;
flex-direction: column;
}
.ChatContainer {
width: 100%;
height: 100%;
display: flex;
flex-direction: column;
gap: 8px;
}
.Chats {
background: lightgray;
flex: 1 1 200px;
min-height: 1lh;
overflow-y: auto;
display: flex;
flex-direction...

Similar Posts

Loading similar posts...

Keyboard Shortcuts

Navigation
Next / previous item
j/k
Open post
oorEnter
Preview post
v
Post Actions
Love post
a
Like post
l
Dislike post
d
Undo reaction
u
Recommendations
Add interest / feed
Enter
Not interested
x
Go to
Home
gh
Interests
gi
Feeds
gf
Likes
gl
History
gy
Changelog
gc
Settings
gs
Browse
gb
Search
/
General
Show this help
?
Submit feedback
!
Close modal / unfocus
Esc

Press ? anytime to show this help