From the course: CSS: Advanced Layouts with Grid
Unlock this course with a free trial
Join today to access over 24,300 courses taught by industry experts.
Justify the grid - CSS Tutorial
From the course: CSS: Advanced Layouts with Grid
Justify the grid
- [Instructor] This layout we've created is restricted to 80% of the viewport width until we get up to our first media query, or see, right there, where we're overriding that restriction. Now this layout will continue to be full width, no matter how wide the viewport gets, and that might be what you're going for, or it might not be. And this lesson, I wanted to show you an interesting way to restrict the max width of a grid layout without using traditional methods. And then I'll show you how to justify the entire grid container. So let's head to our style sheet. To start with the width restriction, let's go to our media query for this 1100 pixels, and instead of the center column taking up 1fr, let's change this to minmax. We'll say auto, 30em. So this says, at a minimum, this column width can auto size itself, but at a maximum it should never be more than 30ems. So let's reload this, and we need to go above 1100 pixels to get to that break point. There we go. So now we see in our…
Contents
-
-
-
-
-
(Locked)
What you're creating: A multi-column layout36s
-
(Locked)
Overview of the starting point3m 13s
-
(Locked)
Create the main grid4m 5s
-
(Locked)
Manual grid item placement4m 21s
-
(Locked)
Add third column for wider viewports4m 26s
-
(Locked)
Justify the grid2m 43s
-
(Locked)
Bonus: Refactor using grid areas4m 44s
-
(Locked)
-
-
-
-
-