Materialize Tutorial #9 - Responsive Grid

Net Ninja · Beginner ·🛠️ AI Tools & Apps ·8y ago
Skills: HTML & CSS70%

Key Takeaways

Explains the 12-column responsive grid system in Materialize

Full Transcript

alright then gang so I want to talk about one of the more widely used layout features of materialized right here and that is the grid system so the grid system allows us to display content in a grid like fashion on a website now if you've been designing websites for a while before or used anything like bootstrap you're probably familiar with a grid system basically it splits up our contents into rows and columns and this particular grid is 12 columns in width that means that if we wanted an element to occupy one column it would take up one column in a width of the website makes sense so you can see there's 12 columns right here and each one of these corresponds to a different div right here but if we wanted an element to take up say four columns or six columns we can do that if you look down here we can see that this D right here is 12 columns wide this one is 6 columns wide so it takes up half the screen and if we scroll down further you might see different examples note we don't but I'm going to show you plenty of them so to start with we need a class of row surrounding all the elements this right here this is a row of elements and each one of these elements these divs inside is specified how many columns in width it's going to take up right here as a class now every element which takes up some kind of column width inside a row that has to have a class of call and then this optional class saying how much is going to take up how much space it's going to take up so let's do a few different examples of this I'm gonna head over to index J s and you can see at the minute we just have a container and we have this H 14 grits so I want to create a new row this is always the first step when we're working with a grid we'll create a row of content so to do that lets do a div with a class of row ok then so then inside this room say for example I want four different elements well they're all going to be divs and they're all going to take up some space in this row so they all need to have a class of Col whenever we take up column width we have a class of cult generally anything directly inside a role has a class of coal like this now I'm going to duplicate this by pressing alt and shift and pressing down a couple of times so we've got four in total so if we look at this I'm gonna save it view in the browser at the minute we don't really see anything that's because we've not given this any kind of width or space but if we say over here first of all content and then I'll do the same down below of content and then the same for these two content and content if we save it now and preview it then we're just going to see these things right here so automatically the default behavior here is that they're taking up the width of the content alright so if we type something in bigger here like you're ready content content then save it automatically it becomes bigger now we don't want to do that we want to say how many columns of width we want each one of these to be so we can say that different screen size is how big we want those columns to be or how many columns we want a particular element to take up so the way we do that is we generally start at small screen sizes working from mobile and up so say for example for small screen sizes I want each one of these divs to take up three columns in width so that's three six nine twelve that's the full grid so I can do that by saying s for small screen then three to say I want it to take up three columns of width for small screens so I'll do the same down here s3 and then the same again s3 and then finally the same again s3 so all of these now are going to take up three columns of width on small screens now if I view this in a browser we can see down here three columns of width which is a quarter a quarter of 12 right because 3 goes into 12 4 times so they're all taking up 3 columns right now and it's not just for small screens it's also for large screens no matter what the screen size at the minute is is taking up three columns of width and yeah it gets bigger but that's because the screen size gets bigger and the overall grid size gets bigger but it's still taking up a quarter of the grade three columns so when we use something like this s3 it means for small screen sizes and up but what if we want to give something a size for the small screens and then for a medium sized screen our allies sized screen we want to give them a different width well we can do that as well what I'm gonna do is grab all this and press alt shift down to duplicate it to create a new row and then inside this wrote what I'll do is say okay for small screens I want this to be six columns in width so if we save this now and view this in a browser and by the way they get these styles this gray background and stuff because I just added a bit of padding background and line height right here and margin between the rows so that you can see these blocks individually but anyway we've given each one of these a class of s 6 which means for small screen sizes and don't give each one of these divs six columns in width so the first to go across and they span the whole grid width then because there's no room left over it goes on to the next line six columns again six columns again and it's the same as we get larger it's always six columns in width now if we wanted for a medium screen and up to have say three columns have wit for each one of these we can say M for medium size 3 M 3 M 3 and you guessed it M 3 so let's save that and view that in a browser and so for small screens it still six columns in width as soon as it gets to a medium sized screen here it goes to three columns in width all the way up to large screens as well okay so that's why it's good to work from the bottom upwards because it's always s 3 meaning three columns for small screens and up until we reach another class where it says M 3 which means for medium sized screens and up give it three columns in width all right so what about larger screens as well well let's do that we're going to highlight that pressed alt shift and down to duplicate it and then what I'll do is also add on two more of these so let me duplicate those as well and then for small screens will do 12 for here so I'm going to alt shift click all of these so I can change them all at once and type in 12 so for small screens each one takes up 12 columns of width then for medium sized screens will do the same alt shift all of these and we want it to be oops made a mistake there won't shift and we want this to be 6 columns in width then when we get to large screens so L I want them to be 4 columns in width save that for you in a browser so start off small you can see they have 12 columns of width each they take up the whole grid width then when we get to medium they take up 6 columns in width then when we get to large they take up 4 columns in width 4 8 12 4 8 12 all right so this is a nice responsive grid now and this is how we can display our content or lay our content out on a web page so that on larger screens they can be next to each other and for smaller screens they can stop all right so let's do one more example what I'm gonna do is just duplicate this one more time and I'm gonna get rid of the last two we only want four elements this time around in fact no we'll keep those we'll keep six okay so we'll say 12 for small screens still 6 for medium screen still but then what we'll do is say what we want to do when it reaches extra-large screens so again I'm going to space or rather first of all I'll alt shift everywhere down here so we only have to write it out once then I'll do space then Excel for extra-large screens then 12 and so I'm seeing wedding nuts well rather - that makes more sense so when it gets to extra large screen sizes we're just going to take up two columns in width so let's save that and view this in a browser starting off small getting bigger which is this one at the bottom then bigger again then finally it should snap to two columns in width so 2 4 6 8 10 12 all right I did say that was the last example but I do want to do one more so shift alt down so duplicate now this time I am just going to do four elements and I just want to show you here that they don't all have to have the same number so so far we've been basically giving each one the same width in columns we don't have to do that what I'm gonna do is just get rid of a lot of this so I'm going to delete all the way down to medium like so and then for this one I'll say okay so for medium screens it up I want this to have eight columns of width this one right here is going to have four so 8 a 4 May 12th that will be one line and then the one below that is gonna have four and then the one below that is going to have eight so if we save this preview in a browser got a small first of all and we can see them stacked at the bottom but then when we get to medium size screens we can see 8 4 4 8 and it goes all the way up then two large screens 8 4 4 8 I'll write them my friends so that is the grid in a nutshell and we will be using it going forward to display different parts of content on our web page

Original Description

Hey, in this Materialize tutorial we'll take a close look at the 12-column responsive grid system. ---------------------------------------- 🐱‍💻 Course Links: + VS Code editor - https://code.visualstudio.com/ + GitHub repository (course files) - https://github.com/iamshaunjp/materialize-playlist +Materialize docs - https://materializecss.com/getting-started.html ---------------------------------------- 🤑 Donate @ https://www.paypal.me/thenetninja 🎓Find me on Udemy @ https://www.udemy.com/user/47fd83f6-5e4a-4e87-a0f0-519ac51f91b6/
Watch on YouTube ↗ (saves to browser)
Sign in to unlock AI tutor explanation · ⚡30

Playlist

Uploads from Net Ninja · Net Ninja · 0 of 60

← Previous Next →
1 Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Regular Expressions (RegEx) Tutorial #14 - Matching a Username
Net Ninja
2 Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Regular Expressions (RegEx) Tutorial #15 - Email RegEx Pattern
Net Ninja
3 Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Regular Expressions (RegEx) Tutorial #16 - Finishing Touches
Net Ninja
4 GraphQL Tutorial #1 - Introduction to GraphQL
GraphQL Tutorial #1 - Introduction to GraphQL
Net Ninja
5 GraphQL Tutorial #2 - A Birdseye View of GraphQL
GraphQL Tutorial #2 - A Birdseye View of GraphQL
Net Ninja
6 GraphQL Tutorial #3 - Project (stack) Overview
GraphQL Tutorial #3 - Project (stack) Overview
Net Ninja
7 GraphQL Tutorial #4 - Making Queries (front-end preview)
GraphQL Tutorial #4 - Making Queries (front-end preview)
Net Ninja
8 GraphQL Tutorial #5 - Express App Setup
GraphQL Tutorial #5 - Express App Setup
Net Ninja
9 GraphQL Tutorial #6 - Setting up GraphQL
GraphQL Tutorial #6 - Setting up GraphQL
Net Ninja
10 GraphQL Tutorial #7 - GraphQL Schema
GraphQL Tutorial #7 - GraphQL Schema
Net Ninja
11 GraphQL Tutorial #8 - Root Query
GraphQL Tutorial #8 - Root Query
Net Ninja
12 GraphQL Tutorial #9 - The Resolve Function
GraphQL Tutorial #9 - The Resolve Function
Net Ninja
13 GraphQL Tutorial #10 - Testing Queries in Graphiql
GraphQL Tutorial #10 - Testing Queries in Graphiql
Net Ninja
14 GraphQL Tutorial #11 - GraphQL ID Type
GraphQL Tutorial #11 - GraphQL ID Type
Net Ninja
15 GraphQL Tutorial #12 - Author Type
GraphQL Tutorial #12 - Author Type
Net Ninja
16 GraphQL Tutorial #13 - Type Relations
GraphQL Tutorial #13 - Type Relations
Net Ninja
17 GraphQL Tutorial #14 - GraphQL Lists
GraphQL Tutorial #14 - GraphQL Lists
Net Ninja
18 GraphQL Tutorial #15 - More on Root Queries
GraphQL Tutorial #15 - More on Root Queries
Net Ninja
19 GraphQL Tutorial #16 - Connecting to mLab
GraphQL Tutorial #16 - Connecting to mLab
Net Ninja
20 GraphQL Tutorial #17 - Mongoose Models
GraphQL Tutorial #17 - Mongoose Models
Net Ninja
21 GraphQL Tutorial #18 - Mutations
GraphQL Tutorial #18 - Mutations
Net Ninja
22 GraphQL Tutorial #19 - More on Mutations
GraphQL Tutorial #19 - More on Mutations
Net Ninja
23 GraphQL Tutorial #20 - Updating the Resolve Functions
GraphQL Tutorial #20 - Updating the Resolve Functions
Net Ninja
24 GraphQL Tutorial #21 - GraphQL NonNull
GraphQL Tutorial #21 - GraphQL NonNull
Net Ninja
25 GraphQL Tutorial #22 - Adding a Front-end
GraphQL Tutorial #22 - Adding a Front-end
Net Ninja
26 GraphQL Tutorial #23 - Create React App
GraphQL Tutorial #23 - Create React App
Net Ninja
27 GraphQL Tutorial #24 - Book List Component
GraphQL Tutorial #24 - Book List Component
Net Ninja
28 GraphQL Tutorial #25 - Apollo Client Setup
GraphQL Tutorial #25 - Apollo Client Setup
Net Ninja
29 GraphQL Tutorial #26 - Making Queries from React
GraphQL Tutorial #26 - Making Queries from React
Net Ninja
30 GraphQL Tutorial #27 - Rendering Data in a Component
GraphQL Tutorial #27 - Rendering Data in a Component
Net Ninja
31 GraphQL Tutorial #28 - Add Book Component
GraphQL Tutorial #28 - Add Book Component
Net Ninja
32 GraphQL Tutorial #29 - External Query File
GraphQL Tutorial #29 - External Query File
Net Ninja
33 GraphQL Tutorial #30 - Updating Component State
GraphQL Tutorial #30 - Updating Component State
Net Ninja
34 GraphQL Tutorial #31 - Composing Queries
GraphQL Tutorial #31 - Composing Queries
Net Ninja
35 GraphQL Tutorial #32 - query variables
GraphQL Tutorial #32 - query variables
Net Ninja
36 GraphQL Tutorial #33 - Re-fetching Queries
GraphQL Tutorial #33 - Re-fetching Queries
Net Ninja
37 GraphQL Tutorial #34 - Book Details Component
GraphQL Tutorial #34 - Book Details Component
Net Ninja
38 GraphQL Tutorial #36 - Styling the App
GraphQL Tutorial #36 - Styling the App
Net Ninja
39 GraphQL Tutorial #35 - Making a Single Query
GraphQL Tutorial #35 - Making a Single Query
Net Ninja
40 Build Apps with Vue & Firebase - Udemy Course
Build Apps with Vue & Firebase - Udemy Course
Net Ninja
41 Updated Vue & Firebase Course (Udemy)
Updated Vue & Firebase Course (Udemy)
Net Ninja
42 Vue & Firebase Real-time Chat (Preview) #1 - Intro
Vue & Firebase Real-time Chat (Preview) #1 - Intro
Net Ninja
43 Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Vue & Firebase Real-time Chat (Preview) #2 - Project Structure
Net Ninja
44 Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Vue & Firebase Real-time Chat (Preview) #3 - Firestore Setup
Net Ninja
45 Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Vue & Firebase Real-time Chat (Preview) #4 - Welcome Screen
Net Ninja
46 Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Vue & Firebase Real-time Chat (Preview) #5 - Props in Routes
Net Ninja
47 Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Vue & Firebase Real-time Chat (Preview) #6 - Route Guards
Net Ninja
48 Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Vue & Firebase Real-time Chat (Preview) #7 - Chat Window
Net Ninja
49 Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Vue & Firebase Real-time Chat (Preview) #8 - New Message Component
Net Ninja
50 Object Oriented JavaScript Tutorial #1 - Introduction
Object Oriented JavaScript Tutorial #1 - Introduction
Net Ninja
51 Object Oriented JavaScript Tutorial #2 - Object Literals
Object Oriented JavaScript Tutorial #2 - Object Literals
Net Ninja
52 Object Oriented JavaScript Tutorial #3 - Updating Properties
Object Oriented JavaScript Tutorial #3 - Updating Properties
Net Ninja
53 Object Oriented JavaScript Tutorial #4 - Classes
Object Oriented JavaScript Tutorial #4 - Classes
Net Ninja
54 Object Oriented JavaScript Tutorial #5  - Class Constructors
Object Oriented JavaScript Tutorial #5 - Class Constructors
Net Ninja
55 Object Oriented JavaScript Tutorial #6 - Class Methods
Object Oriented JavaScript Tutorial #6 - Class Methods
Net Ninja
56 Object Oriented JavaScript Tutorial #7 - Method Chaining
Object Oriented JavaScript Tutorial #7 - Method Chaining
Net Ninja
57 Object Oriented JavaScript Tutorial #8 - Class Inheritance
Object Oriented JavaScript Tutorial #8 - Class Inheritance
Net Ninja
58 Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Object Oriented JavaScript Tutorial #9 - Constructors (under the hood)
Net Ninja
59 Object Oriented JavaScript Tutorial #10 - Prototype
Object Oriented JavaScript Tutorial #10 - Prototype
Net Ninja
60 Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Object Oriented JavaScript Tutorial #11 - Prototype Inheritance
Net Ninja

Related Reads

📰
How I Built a Free Online Image & PDF Processing Platform with Vue 3 + FastAPI
Learn how to build a free online image and PDF processing platform using Vue 3 and FastAPI, and discover the benefits of combining these technologies for efficient file processing
Dev.to · IAMUU
📰
I Built a Free AI-Powered YouTube SEO Toolkit With Zero Budget. Here’s What Actually Happened.
Learn how a solo dev built a free AI-powered YouTube SEO toolkit with zero budget and the lessons they learned from the experience
Medium · Startup
📰
How to Create a Second Version of Yourself Inside Obsidian Using AI (Step-by-Step Guide)
Learn to create a second version of yourself inside Obsidian using AI with a step-by-step guide
Medium · ChatGPT
📰
How to prepare for Spain civil service TIC exam using AI in 2026
Learn how to prepare for the Spain civil service TIC exam using AI in 2026, boosting your chances of success with technology-driven study techniques
Dev.to · David García
Up next
I Asked Gemini to Build a Dashboard... I Didn't Expect This
Patech
Watch →