This is the sixth part in a seven-part series about the JavaScript framework, Angular 5.
In this part, we’ll go over adding Flex-Layout to our application to make it responsive.
This is not intended to be a complete guide, but rather an overview of the basics to get you up and running so you can get to know Flext-Layout and how to use it with Angular 5 Material.
Article Series:
Final Demo here
If you want to add a touch styling to your Angular application you have to use one of the CSS Libraries, but Angular Material is specially designed for Angular. But it does not have a grid system, so we need to add one or build it ourself.
In the Angular Material article I created a simple grid using flex, but you can use Flex-Layout for more complex uses.
Some people won’t like Flex-Layout and would prefer using css flex. It’s up to you.
But in this article I’ll talk about how to use Flex-Layout with Angular Material and we’ll turn our previous posts into grid using Flex-Layout.
In our application root run:
Now we have to import FlexLayoutModule into our app.module.ts
Here’s my app.module.ts
Let’s use Flex-Layout with our home posts.
I’ll use the next code to create our grid
To create 4 posts in one row I’ll make fxFlex= 20%. and put your post code instead of the comment, and repeat this part as you want.
Open src/app/home/home.component.html
Check the flex-layout documentation for more complex uses.
Now you can remove our css code in home.component.scss.
Next: Building News App using Angular 5
Some useful Links:
- 👨️ My Website/Portfolio
- 🔥 Get your $50 in FREE hosting credit HERE
- 🤑️ No Stripe? How To Get Paid With Payoneer ⇒ $25 + $10 Sign UP Bonus