I was looking at this question: The difference between percentage and fr units in CSS Grid Layout and understood that fr
works for free space in the container. And I tried checking it which causes a confusion.
In this pen both %
and fr
acts like entirely same.
In a code like below:
main {
width: 1000px;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
// grid-template-columns: repeat(3, 33%);
}
I was under the impression that:
- If you try
33%
the container will split into 3 equal parts regardless of length of the content of each grid item (which is working as expected.) - If you try
1fr
, each grid item will get the exact same portion of the free space (divided by three in this case) available after the content's length in the width of the container. ie, the middle will get more space because it will get the portion from left and right parts.
But in each case, I'm getting the same width. Why?