CSS Grid Course: Named Lines
Key Takeaways
This video covers the concept of named lines in CSS Grid, allowing for easier placement and sizing of items on the grid using names instead of numbers. The instructor demonstrates how to define named lines, use them to position items, and apply grid area to create a more efficient layout.
Full Transcript
heyyyyyy in this screencast you're going to learn a new way of positioning and sizing the items on the grid using something called named lines so we have to find our normal grid here which is the website layout you should be familiar with by now though in this case we're defining it in the very simple way of only having two columns one being one fraction unit and one being five fraction units so we're not using the flexible twelve column layout here as this setup makes it easier when you sing named lines so to brush up a little bit the grid has column lines and row lines and the first column line is the one on the left hand side the second one is one separating the two columns and the third one is the one on the far right hand side and our content item for example is defined to span from the second row line to the third row line from here to here in our code that will be from the line that goes in between here and until the line that goes here so what we now can do is we can add a square bracket in between and write confident start for example on the third line write confident and like that now what we can do is we can swap out the number two here with content start and the number three with open end like that as you can see that works fine if we wanted to do the same thing for the header we'd have to give a name to the first line as well up here let's call that main start so now the header spans from main start to content end however I actually want to call this line main end as well because there might be a case in the future where we're going to reference the main end explicitly not use content end as a proxy for it so so let's just add a new name here paint and like that could give it a space and then the new name now we can do main art mane and as you can see works perfectly fine the footer can get the exact same layout like that now let's also name the rows using the exact same convention will do main start I'm just going to copy them I'm going start end and main end like that now you might wonder why we've been using this - syntax here and that's because they give you a little bit of magic now given that we've called this line here for content start and this line here for content end the grid knows that this is the content column or columns if that was the case so you can actually set the grid column to just content like that and as you can see it works now the header and the footer spans from main start to main and so we can do the exact same thing there as well just use grid column main and to take this even a step further actually we can also use grid area in one of these cases that'll be in the content case because let's have a look at the content lines both the row lines and the column lines so we know we have the content start here and the content and here though we also have a Content start here the second row line first second so this one here and we have a content end on the third row line the third one here meaning we have boxed in an area with content lines here here here here and here and now we can actually use grid area which you which you might remember from section one of this course are simply different grid area and set it to content like that and it still works however you might be tempted to try and do the same thing down on the footer though that wouldn't work because it has to be boxed in by four main lines though the main start row line is the one that starts up here not down here above the footer so here we have only kind of boxed it partially in we have the main start column line here which is the start of the footer and the main end row line just the bottom of the footer and the main end column line which is the right-hand side of the footer though the top of the footer is the content and line so we can't use grid area main here as you can see it breaks the entire layout so be careful and make sure that you have properly boxed in an area before you start using grid area okay now is it for this bonus screencast thank you
Original Description
Check out the full CSS Grid course for free here: https://scrimba.com/g/gR8PTE
Named lines make it easier to understand how items are placed, as you can use names instead of numbers when you place your items.
Playlist
Uploads from Scrimba · Scrimba · 9 of 60
1
2
3
4
5
6
7
8
▶
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
CSS Grid Course: Learn the Basics in 3 Minutes
Scrimba
CSS Grid Course: Positioning Items
Scrimba
CSS Grid Course: Why Learn It And How It Compares To Bootstrap
Scrimba
CSS Grid Course: auto-fit & minmax
Scrimba
CSS Grid Course: Implicit Rows
Scrimba
CSS Grid Course: Fraction Units And Repeat
Scrimba
CSS Grid Course: Justify Items and Align Items
Scrimba
CSS Grid Course: An Awesome Image Grid
Scrimba
CSS Grid Course: Named Lines
Scrimba
CSS Grid Course: auto-fit vs auto-fill
Scrimba
CSS Grid Course: Justify Content and Align Content
Scrimba
CSS Grid Course: Template areas
Scrimba
27. Setting up the structure - Responsive CSS Tutorial
Scrimba
25. Making the navigation responsive - Responsive CSS Tutorial
Scrimba
36. Playing with the title's position and negative margins - Responsive CSS Tutorial
Scrimba
31. Starting the CSS for our page - Responsive CSS Tutorial
Scrimba
26. Taking a look at the rest of the project - Responsive CSS Tutorial
Scrimba
15. Spacing out the columns - Responsive CSS Tutorial
Scrimba
33. Starting to think mobile first - Responsive CSS Tutorial
Scrimba
22. Making our navigation look good - Responsive CSS Tutorial
Scrimba
37. Changing image size with object-fit - Responsive CSS Tutorial
Scrimba
44. Module Wrap up - Responsive CSS Tutorial
Scrimba
16. Controlling the vertical position of flex items - Responsive CSS Tutorial
Scrimba
39. Setting up the widgets and talking breakpoints - Responsive CSS Tutorial
Scrimba
42. Setting up the About Me page - Responsive CSS Tutorial
Scrimba
35. Changing the visual order with flexbox - Responsive CSS Tutorial
Scrimba
23. Adding the underline - Responsive CSS Tutorial
Scrimba
21. Using flexbox to start styling our navigation - Responsive CSS Tutorial
Scrimba
20. Creating a navigation - Responsive CSS Tutorial
Scrimba
40. Using a new pseudo class to wrap up the homepage - Responsive CSS Tutorial
Scrimba
43. Fixing up some loose ends - Responsive CSS Tutorial
Scrimba
32. Starting the layout. Looking at the big picture - Responsive CSS Tutorial
Scrimba
24. A more complicated navigation - Responsive CSS Tutorial
Scrimba
28. Feature article structure - Responsive CSS Tutorial
Scrimba
34. Styling the featured article - Responsive CSS Tutorial
Scrimba
18. Making layout responsive with flex direction - Responsive CSS Tutorial
Scrimba
19. flex direction explained - Responsive CSS Tutorial
Scrimba
41. Creating the recent posts page - Responsive CSS Tutorial
Scrimba
17. Media Query basics - Responsive CSS Tutorial
Scrimba
30. Home Page. HTML for the aside - Responsive CSS Tutorial
Scrimba
38. Styling recent articles for large screens - Responsive CSS Tutorial
Scrimba
29. The home page. HTML for the recent articles - Responsive CSS Tutorial
Scrimba
10. ems and rems an example - Responsive CSS Tutorial
Scrimba
1. Starting to think responsively - Responsive CSS Tutorial
Scrimba
4. Controlling the width of images - Responsive CSS Tutorial
Scrimba
5. min width and max width - Responsive CSS Tutorial
Scrimba
3 CSS Units. Percentage - Responsive CSS Tutorial
Scrimba
11. Flexbox refresher and setting up some HTML - Responsive CSS Tutorial
Scrimba
12. Basic Styles and setting up the columns - Responsive CSS Tutorial
Scrimba
8. The Solution Rems - Responsive CSS Tutorial
Scrimba
14. Setting the columns widths - Responsive CSS Tutorial
Scrimba
2 CSS Units - Responsive CSS Tutorial
Scrimba
7. The problem with ems - Responsive CSS Tutorial
Scrimba
6. CSS Units. The em unit - Responsive CSS Tutorial
Scrimba
13. Adding the background color - Responsive CSS Tutorial
Scrimba
9. Picking which unit to use - Responsive CSS Tutorial
Scrimba
Tutorial to Learn Alpine JS - Full Course for Beginners
Scrimba
Guide To Algorithms in Javascript [Binary Search] - Full Course / Tutorial
Scrimba
Learn UI Design [7 Fundamentals Tutorial] - Full Course for Beginners
Scrimba
Javascript Tutorial for Beginners [From 0 to ES6+] - Full Course
Scrimba
More on: HTML & CSS
View skill →Related Reads
📰
📰
📰
📰
From One Dev to a Team of Eight: The Frontend Architecture Decisions That Didn’t Age Well
Medium · JavaScript
React 19.3: The Interesting Parts Aren’t the Animations
Medium · JavaScript
Mechanics of Virtualization in the Frontend
Medium · JavaScript
When Software Transformed My Frontend Thinking
Medium · Programming
🎓
Tutor Explanation
DeepCamp AI