0

I am learning CSS Grid and cannot figure out how to move the content from first column to the second column (concerning Desktop view +1200 Px). I want to achieve some basic center alignment, just like with margin: 0 auto. Thats why I put 1fr before the 4 columns and 1fr after the 4 columns (grid-template-columns: 1fr repeat(4, minmax(auto, 250px)) 1fr;). But the content gets fit into the fist column - which is meant to center the 4 content columns. I hope you understand what I mean. Please expand window to see the Desktop width.

<https://jsfiddle.net/freshynek/d3bzLgvh/>.   
1
  • Please add all relevant code in the question itself. Ping me when it's done and I'll reverse my downvote. Commented Feb 17, 2021 at 16:23

1 Answer 1

2

The content is meant to go into the first column. You should remove that 1fr from your template (it's a hack and will not work). Instead use justify-content: center; to center div.grid.

Edit: In theory you could add an empty div (<div></div>) before your first card. So the first column would be empty and the second column would contain your desired content. However as I said, this is a hack and if you're learning how to use grid you're better off not relying on hacks.

Sign up to request clarification or add additional context in comments.

1 Comment

O.K. I edited the code according to your suggestion. Is this correct now? jsfiddle.net/freshynek/d3bzLgvh/5.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.