Tuesday, July 30, 2019

Intrinsically Responsive CSS Grid with minmax() and min()

The most famous line of code to have come out of CSS grid so far is:

grid-template-columns: repeat(auto-fill, minmax(10rem, 1fr));

Without any media queries, that will set up a grid container that has a flexible number of columns. The columns will stretch a little, until there is enough room for another one, and then a new column is added, and in reverse.

The only weakness here is that first value in minmax() (the 10rem value above). If the container is narrower than whatever that minimum is, elements in that single column will overflow. Evan Minto shows us the solution with min():

grid-template-columns: repeat(auto-fill, minmax(min(10rem, 100%), 1fr));

The browser support isn't widespread yet, but Evan demonstrates some progressive enhancement techniques to take advantage of now.

Direct Link to ArticlePermalink

The post Intrinsically Responsive CSS Grid with minmax() and min() appeared first on CSS-Tricks.

from CSS-Tricks http://evanminto.com/blog/intrinsically-responsive-css-grid-minmax-min/

The blog post Intrinsically Responsive CSS Grid with minmax() and min() Find more on: https://www.instant-web-site-tools/



source https://www.instant-web-site-tools.com/2019/07/31/intrinsically-responsive-css-grid-with-minmax-and-min/

No comments:

Post a Comment

40+ Best Minimal Logo Design Templates

Minimalist logo design is an art. How can you convey your brand with a professional logo, but keep the simplicity of a minimal, clean, and s...