Everything you need to know about flex box. Make awesome websites

No matter you are a beginner or pro. If you want to make extraordinary Web sites. If you want make amazing UI/UX, then you must read this advance CSS series article. In this article, we’ll talk about CSS flex box. Flex box is important in CSS and with …

No matter you are a beginner or pro. If you want to make extraordinary Web sites. If you want make amazing UI/UX, then you must read this advance CSS series article. In this article, we’ll talk about CSS flex box. Flex box is important in CSS and with this we can make any sort of web site easily. If you follow this CSS series believe me you’ll be able to make amazing websites as I do. In today’s article, you will learn about flex box, and its use cases, and some of its properties. So let’s quickly jump into it.



Video Explanation

You can also watch the video explanation 😊



Who I am ?

Before we start, if you don’t know me. Well, I am Kunaal from India manage Modern Web YouTube channel. I make content on web development to master your web dev skills, I made tutorials on Fullstack Ecom website,Personal Portfolios, Fullstack Blogging website, Amazing Headers Animations and much more. If that excites you, you can visit my channel.

Let’s start now.



What is Flex box & Why we need it.

Well before we see how we can use flex box. I guess its important that we see why we need it. In my perspective this is the best way to learn.

CSS Flex Box

You can see the above illustration, in that you can clearly see even though my H1 element is covering the blue part only, but still it has full width and covering the whole space the red part. And because of that the p element is coming below the h1. Well this is happening because, in HTML almost every elements are considered as a HTML block. And because of it they have full width.

But what if, I want to make the elements side by side. Well I said all the elements are like a block, so can’t we make them side by side. Well for exactly this purpose, we have flex box in CSS.

CSS Flex Box



How to use flex box ?

So once we know when we need to use flex box. Then we can see how to use it. So in CSS, we access or use flex box using display: flex.

Well, if you ever used display property in CSS. You know we give it directly to the element. What do I mean with that ?

ummm! I mean for instance, If I want to hide any element let say h1 element. Then I will use display:none.

h1{
   display: none;
}

The above code will hide the the h1 element. So can we use flex like this.

CSS Flex Box

Well, even though we use flex box using display property. We don’t give this directly to the element. We give this to the nearest parent element. You can see in above illustration, both h1 and p elements, have a common nearest parent element which is body element. So we will give display: flex to body element. I hope you understand because it is very important, most people forget this all the time that they should add display: flex to the nearest parent.

Now, let’s see some if its properties cause without the properties, It’ll not be fun to use flex box.



Justify Content

CSS Flex box

Justify content property is used to align the children in horizontal axis. You can refer to the above image.

Let’s see some of its value. And of course we give this to nearest parent element.

Frame 3 (1)



Align Items

CSS Flex Box

Well, on side justify content place children in X axis, so align-items place the children in Y axis. You can refer the above image.

Some of it’s properties.

Alt Text



Flex Wrap

CSS Flex Box

The main reason of using flex is responsiveness, so how can achieve that. Well flex-wrap basically wraps or break the flow of flex box. making the website responsive.

Frame 2 (7)



Flex Direction

CSS flex Box

Now, flex-direction its very simple, its just change the flow of flex box.

Frame 1 (2)



Some other properties.

Up until now, all the properties we saw, we give them to nearest parent. But we have some more properties which we give directly to the children or specific element.

CSS Flex Box

The above properties not use more often, that’s why I am not telling you, but if you want you can check them in my other article here.



Wrap up

So, that’s it. That was all about CSS Flex box. If you liked the article and found it helpful, make sure sure to follow me and you can also show your appreciation by simply subscribing my youtube channel. I make awesome web dev content though 😉

So, As I decided to make advance CSS series, then I will do it on my style. And according to me its not enough that I’ll tell you how to use it. You also have to practice it. For that, I made 3 designs for you that you can make using flex box for practice.

Design 1, Design 2, Design 3

Well, make sure you code the above designs, it will motivate me to continue this CSS series. And make sure to submit it to me by tagging me on my instagram @modern_web_channel

If you stuck anywhere, or have any doubt feel free to ask me.

Thanks for reading 😊



Articles you may find Useful

  1. Best CSS Effect
  2. Infinte CSS loader
  3. Disney+ Clone
  4. Youtube API – Youtube Clone
  5. TMDB – Netflix Clone

Print Share Comment Cite Upload Translate
APA
Modern Web | Sciencx (2024-03-29T13:44:24+00:00) » Everything you need to know about flex box. Make awesome websites. Retrieved from https://www.scien.cx/2022/01/01/everything-you-need-to-know-about-flex-box-make-awesome-websites/.
MLA
" » Everything you need to know about flex box. Make awesome websites." Modern Web | Sciencx - Saturday January 1, 2022, https://www.scien.cx/2022/01/01/everything-you-need-to-know-about-flex-box-make-awesome-websites/
HARVARD
Modern Web | Sciencx Saturday January 1, 2022 » Everything you need to know about flex box. Make awesome websites., viewed 2024-03-29T13:44:24+00:00,<https://www.scien.cx/2022/01/01/everything-you-need-to-know-about-flex-box-make-awesome-websites/>
VANCOUVER
Modern Web | Sciencx - » Everything you need to know about flex box. Make awesome websites. [Internet]. [Accessed 2024-03-29T13:44:24+00:00]. Available from: https://www.scien.cx/2022/01/01/everything-you-need-to-know-about-flex-box-make-awesome-websites/
CHICAGO
" » Everything you need to know about flex box. Make awesome websites." Modern Web | Sciencx - Accessed 2024-03-29T13:44:24+00:00. https://www.scien.cx/2022/01/01/everything-you-need-to-know-about-flex-box-make-awesome-websites/
IEEE
" » Everything you need to know about flex box. Make awesome websites." Modern Web | Sciencx [Online]. Available: https://www.scien.cx/2022/01/01/everything-you-need-to-know-about-flex-box-make-awesome-websites/. [Accessed: 2024-03-29T13:44:24+00:00]
rf:citation
» Everything you need to know about flex box. Make awesome websites | Modern Web | Sciencx | https://www.scien.cx/2022/01/01/everything-you-need-to-know-about-flex-box-make-awesome-websites/ | 2024-03-29T13:44:24+00:00
https://github.com/addpipe/simple-recorderjs-demo