FAQ: CSS Grid Essentials - minmax

This community-built FAQ covers the “minmax” exercise from the lesson “CSS Grid Essentials”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn CSS

FAQs on the exercise minmax

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Is there a way to control height or width when using minmax(). It seems the property changes at random when adjusting size of the entire grid…

1 Like

I agree. In this specific exercise, setting the lower bound as 50px, my grid doesn’t appear to ever approach this value, even when significantly narrowing the browser window.

2 Likes

Hello!
Can I use the minmax function in the condensed version of the grid-template or do i need to specify the separate columns and rows?

Any help is appreciated.
Thank you!
Sara

The issue is that the other columns are sized with fr and will only split up what’s left of the width after the others have taken their share. This means the middle column takes it’s max of 300px as long as the grid is wider than 300px.

It is a pretty bad example to show off what minmax does.

But set the first column to a fixed 200px and you will see that it works fine. In a wide window, A is 200px, B is 300px and C takes up the rest. When you are narrowing the window first C will shrink until it can barely contain the letter C then B will shrink until it’s 50px wide and then a scrollbar appears at the bottom of the window because the grid is now at the absolute minimum width.

27 Likes

Thank you, I had the same questions I could stretch the middle columns to max 300px, but I could not reduce it to min 50px…Now it makes more sense.:+1:

The minmax() enables us to restrict the range of row or column size. But what determines the size of these attributes? And what would be the default value of the row or column in question.

2 Likes

Hey everyone, I need help with page 8, Instruction #2. It says " Using minmax() , change the second column to be between 50 pixels and 300 pixels." I can’t seem to figure out the correct way to do this. Here is what I have:

image

Adding minmax(50px, 300px) right after the 50%, which is indeed the second column, adds another column and messes up the size. The examples in the lesson shows it embedded in the same way, so what am I doing wrong? Thanks to anyone who can help!

Update: I figured it out. It doesn’t want you to make that 50% between 50px-300px, it wants you to literally replace it with that. Here is the correct code:

image

I wish this was more clear, but it brings a question. the minmax(value, value) adds a column instead of specifying the previous one? I guess that makes more sense than what I thought. It basically is saying “Hey, make a new column between 50 -300px based on the device.” Would it max out the 300px if the device was wide enough?

4 Likes

Definitely given a bad example in the lesson

1 Like

If I get super stuck or the lesson is buggy, I sometimes just press ‘Get Unstuck’ in the bottom right corner of the lesson and look at the solution. Just letting ppl know because some lessons are confusingly worded or buggy :slight_smile:

1 Like

I set the 1st and 3rd column with fixed value of 100px and 200px respectively. However, the middle column still won’t resize down to 50px when I change the window size.

When my window reaches certain width, it won’t size down smaller. Does anyone know why my window is restricted from sizing down further? Thank :slight_smile:

What if we have 2 minmax() functions? What if we need 2 minmax functions? Will css be able to accommodate it?

I tried the code below to set up a grid, but when I use an fr unit in the minmax every element span the width to the container. I thought the unit fr is only supposed to take up a remaining fraction of available space?

grid-template: repeat(3, 100px) / repeat(2, minmax(1fr,400px) 50px);

That has helped me a lot!!

This is an old comment but it helped me as well so saying thanks :grin: