CSS

🎯 CSS grid-auto-columns Property

grid-auto-columns is a CSS Grid property that defines the width of automatically created columns. When a grid item is placed outside the existing structure, new columns are generated and their width is controlled by this property.

🔹 Values

1️⃣ auto

Column width is automatically calculated based on content.

2️⃣ max-content

Column expands to fit the maximum size of its content.

3️⃣ min-content

Column shrinks to the minimum size required by its content.

4️⃣ length (px, %, fr, rem)

You can define a fixed or flexible column width using units like px, %, or fr.

CSS

.grid {
    display: grid;
    grid-auto-columns: 200px;
}
                

5️⃣ initial

Resets the property to its default value.

  • 🧠 Quick Summary

  • grid-auto-columns controls the width of automatically created grid columns.
  • auto → based on content.
  • min-content / max-content → content-based sizing.
  • length → fixed or flexible size.