CSS Grid Content

Text content, like a blog post, can have embedded elements, like images and tables.

For readability, a line of text should have a limited length, to reduce the space the eye has to jump between the end of one line and the start of the next.

To constrain the column with grid, set a max width.

.container {
  display: grid;
  
  /* Auto expand width, max 48rem */
  grid-template-columns: minmax(auto, 48rem);
  
  /* No minimum size, allow enlarging */
  grid-template-columns: fit-content(48rem); 
  
  /* No minimum size, no enlarging */
  grid-template-columns: max(48rem);
}

https://codepen.io/mortona42/pen/qBeaarN

Level
Topics