Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS

grid container min and max width?

Hello, I have a grid-container that has a background color, but upon resizing the browser the grid shrinks, however the items stay the same. my code for the grid to stay the same size is:-

min-width: 620px;
max-width: 620px;
Now it doesn't move which is ideal but probably not how this should be done, does grid container have an simpler way of fixing the movement in place?

I've now gone with

.grid-container2 {
display: grid;
grid-template-columns: auto auto auto;
gap: 10px;
background-color: #2196F3;
padding: 10px;
max-width: 75%;
}

Would that be good coding?

1 Answer

Do you want the container to remain at 620px or scale at 75%? You can shorten min-width/max-width to width: 620px.