From the course: Responsive Layout
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Aligning individual grid items - HTML Tutorial
From the course: Responsive Layout
Aligning individual grid items
- [Instructor] Next we're going to change the alignment of individual items on the grid. We're going to apply the style to the item, rather than the container. Justify-self aligns a grid item in its cell along the horizontal axis. You're overwriting whatever you set for the whole grid with justify items, and the values here are the same. In my exercise here, we're starting with justify items and align items, both set to stretch. So I'm going to add some CSS here for item two on line 17. And it's justify-self: stretch. Save, and it's default, so nothing changes. I'm gonna change that to start, save, and refresh. Now item two, and only item two, is aligned all the way to the left, the starting line of that cell. Change that to end, and refresh. It goes to the end of that cell. Center again puts it right there in the middle. Then I also have align-self, which does the same thing, but this time along the vertical axis instead of the horizontal axis. Similarly, you're overwriting whatever…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
Intro to CSS Grid2m 10s
-
(Locked)
Defining rows and columns3m 55s
-
(Locked)
Grid gap1m 52s
-
(Locked)
Sizing rows and columns5m 52s
-
(Locked)
Placing grid items5m 51s
-
(Locked)
Grid alignment overview1m 13s
-
(Locked)
Aligning tracks3m 46s
-
(Locked)
Aligning grid items within tracks2m
-
(Locked)
Aligning individual grid items1m 47s
-
(Locked)
Variable columns4m 45s
-
(Locked)
Grid template areas4m 12s
-
(Locked)
Naming grid lines2m 47s
-
(Locked)
Ordering grid items1m 16s
-
(Locked)
Grid flow and implicit tracks3m 55s
-
(Locked)
Challenge: The rainbow box1m 9s
-
(Locked)
Solution: The rainbow box6m 42s
-
-
-
-