What does grid-template-columns: repeat(3, 1fr) do in a grid container?

Study for the CSS Mastery Recipient Portal Test. Explore flashcards and multiple choice questions with hints and explanations to prepare for your exam!

Multiple Choice

What does grid-template-columns: repeat(3, 1fr) do in a grid container?

Explanation:
Using fractional units to allocate space, grid-template-columns with repeat(3, 1fr) sets up three grid tracks that each take an equal share of the available width. The repeat() function repeats the same size three times, so you get three tracks, each sized 1fr. The 1fr unit means one portion of the remaining space in the grid container. Because all three columns use 1fr, that remaining space is divided evenly among them, giving three equal-width columns that fill the container. If the container is 900px wide and there are no other constraints, each column will be 300px wide (adjusting for any gaps, padding, or borders). This differs from fixed widths, which would force a specific pixel size, or auto sizing, which would size columns to fit their content.

Using fractional units to allocate space, grid-template-columns with repeat(3, 1fr) sets up three grid tracks that each take an equal share of the available width. The repeat() function repeats the same size three times, so you get three tracks, each sized 1fr. The 1fr unit means one portion of the remaining space in the grid container. Because all three columns use 1fr, that remaining space is divided evenly among them, giving three equal-width columns that fill the container. If the container is 900px wide and there are no other constraints, each column will be 300px wide (adjusting for any gaps, padding, or borders). This differs from fixed widths, which would force a specific pixel size, or auto sizing, which would size columns to fit their content.

Subscribe

Get the latest from Examzify

You can unsubscribe at any time. Read our privacy policy