Sophie Au

Software Developer, Web Designer, Tea Enthusiast

CSS Grid Tips and Tricks

23 August 2020

Have one column in content width, let the other(s) take the remaining space

.grid {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
}

When:

23.05.2020

16:45

Where:

Brandenburger Tor

Germany

Not using minmax(0, 1fr) but just going with 1fr allowes the content to break out of the container (grey background). This is, because 1fr is shorthand for minmax(auto, 1fr).

With 1fr only (i.e. minmax(auto, 1fr)):

When:

23.05.2020

16:45

Where:

Brandenburger_Tor,_which_is_somewhere_in_Berlin.

Germany

With minmax(0,1fr) (which isn't great either but illustrates the point):

When:

23.05.2020

16:45

Where:

Brandenburger_Tor,_which_is_somewhere_in_Berlin.

Germany

Reference: