<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: CodingPorium</title>
    <description>The latest articles on DEV Community by CodingPorium (@codingporium).</description>
    <link>https://dev.to/codingporium</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F655795%2Fc2f51559-bfc6-4376-ae8f-215bbbd220a3.jpg</url>
      <title>DEV Community: CodingPorium</title>
      <link>https://dev.to/codingporium</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/codingporium"/>
    <language>en</language>
    <item>
      <title>Learn CSS Flexbox in 5 Minutes!</title>
      <dc:creator>CodingPorium</dc:creator>
      <pubDate>Mon, 16 Aug 2021 11:10:48 +0000</pubDate>
      <link>https://dev.to/codingporium/learn-css-flexbox-in-5-minutes-1o71</link>
      <guid>https://dev.to/codingporium/learn-css-flexbox-in-5-minutes-1o71</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--CyclRPZB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xmqezw3fwjcbpetcakq9.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CyclRPZB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xmqezw3fwjcbpetcakq9.jpg" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;/p&gt;
&lt;span&gt;&lt;br&gt;&lt;/span&gt;
&lt;p&gt;&lt;span&gt;&lt;b&gt;THIS POST WAS WRITTEN BY ME ALSO MY BLOG. YOU MAY READ IT AT &lt;a href="https://codingporium.blogspot.com/2021/08/learn-css-flexbox-in-5-minutes-collab.html"&gt;HERE&lt;/a&gt;&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Hey friends, today I'll explain all you need to know to start using a CSS Flex box. Before we dive in, i'll introduce myself.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I'm CodingPorium and I make coding tutorials and provide Free Source Code. I'm a newbie to YouTube, but I have experience in front-end web development for over 3 years. Do check out my YouTube channel at &lt;a href="https://youtube.com/channel/UCLjS1fau8etNm-24r5kgxhQ"&gt;here&lt;/a&gt; or by searching for CodingPorium on YouTube for more!&lt;/span&gt;&lt;/p&gt;
&lt;h3&gt;&lt;span&gt;Basics&lt;/span&gt;&lt;/h3&gt;
&lt;p&gt;&lt;span&gt;Alright, let's dive in to the tutorial now. Flex is a display type that enables cards or any div to appear beside each other in a row. There are certain properties of flex box that make it famous such as it's responsiveness and more. Let's see how to use the basic flex display followed by other properties.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;We first add the HTML code below:&lt;/span&gt;&lt;/p&gt;

&lt;pre&gt;&lt;span&gt;&amp;lt;div&lt;/span&gt; &lt;span&gt;class=&lt;/span&gt;&lt;span&gt;"flex-box"&lt;/span&gt;&lt;span&gt;&amp;gt;&lt;/span&gt;
  &lt;span&gt;&amp;lt;div&amp;gt;&lt;/span&gt;1&lt;span&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span&gt;&amp;lt;div&amp;gt;&lt;/span&gt;2&lt;span&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
  &lt;span&gt;&amp;lt;div&amp;gt;&lt;/span&gt;3&lt;span&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;  
&lt;span&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/pre&gt;

&lt;p&gt;&lt;span&gt;Then, we add the CSS Code below:&lt;/span&gt;&lt;/p&gt;


&lt;pre&gt;&lt;span&gt;.flex-box&lt;/span&gt; {&lt;br&gt;
  &lt;span&gt;display&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; flex;&lt;br&gt;
}&lt;br&gt;
&lt;span&gt;.flex-box&lt;/span&gt; &lt;span&gt;&amp;gt;&lt;/span&gt; &lt;span&gt;div&lt;/span&gt; {&lt;br&gt;
  &lt;span&gt;background&lt;/span&gt;&lt;span&gt;:&lt;/span&gt;&lt;span&gt;white&lt;/span&gt;;&lt;br&gt;
  box&lt;span&gt;-&lt;/span&gt;shadow&lt;span&gt;:&lt;/span&gt; rgba(&lt;span&gt;0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;0&lt;/span&gt;&lt;span&gt;,&lt;/span&gt; &lt;span&gt;0&lt;/span&gt;&lt;span&gt;.&lt;/span&gt;&lt;span&gt;24&lt;/span&gt;) &lt;span&gt;0px&lt;/span&gt; &lt;span&gt;3px&lt;/span&gt; &lt;span&gt;8px&lt;/span&gt;;&lt;br&gt;
  &lt;span&gt;margin&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; &lt;span&gt;10px&lt;/span&gt;;&lt;br&gt;
  &lt;span&gt;border&lt;/span&gt;&lt;span&gt;-&lt;/span&gt;radius&lt;span&gt;:&lt;/span&gt;&lt;span&gt;10px&lt;/span&gt;;&lt;br&gt;
  &lt;span&gt;padding&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; &lt;span&gt;20px&lt;/span&gt;;&lt;br&gt;
  &lt;span&gt;font-size&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; &lt;span&gt;30px&lt;/span&gt;;&lt;br&gt;
}&lt;br&gt;
&lt;/pre&gt;
&lt;br&gt;&lt;span&gt;The output would look like this:&lt;/span&gt;&lt;span&gt;&lt;a href="https://lh3.googleusercontent.com/-U7VhoQ6BgMg/YQtpFUSt3QI/AAAAAAAAAFA/6y2VGJ53vtYaqO-ReYx0HUIZc--FYD7pQCLcBGAsYHQ/image.png"&gt;&lt;img alt="" src="https://res.cloudinary.com/practicaldev/image/fetch/s--zYtVGYMl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/-U7VhoQ6BgMg/YQtpFUSt3QI/AAAAAAAAAFA/6y2VGJ53vtYaqO-ReYx0HUIZc--FYD7pQCLcBGAsYHQ/image.png"&gt;&lt;/a&gt;&lt;/span&gt;&lt;span&gt;If you observe the CSS code, you will understand that we only added display of flex for our flex box. Below it, we styled the boxes by giving them padding,color,and more. The main code necessary here is the &lt;/span&gt;&lt;span&gt;display:flex;&lt;/span&gt;&lt;span&gt; Next, we will look on the properties of flex to make it better.&lt;/span&gt;&lt;span&gt;&lt;br&gt;&lt;/span&gt;&lt;h3&gt;&lt;span&gt;1. Flex Direction&lt;/span&gt;&lt;/h3&gt;
&lt;span&gt;The flex-direction property determines whether you would like the flex to arrange from left to right, right to left, top to bottom or bottom to top. Below is the code for all these 4 directions. Row is for horizontal and Column is for vertical. &lt;/span&gt;&lt;span&gt;&lt;br&gt;&lt;/span&gt;


&lt;pre&gt;   &lt;span&gt;flex-direction&lt;/span&gt;&lt;span&gt;:row&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;br&gt;
   &lt;span&gt;flex-direction&lt;/span&gt;&lt;span&gt;:row-reverse&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;br&gt;
   &lt;span&gt;flex-direction&lt;/span&gt;&lt;span&gt;:column&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;br&gt;
   &lt;span&gt;flex-direction&lt;/span&gt;&lt;span&gt;:column-reverse&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;br&gt;
&lt;/pre&gt;
&lt;br&gt;&lt;span&gt;For an example, I will be using flex-direction:column in the photo below. The output would look like:&lt;/span&gt;&lt;br&gt;&lt;a href="https://lh3.googleusercontent.com/-3uySrDeAnNU/YQtp_N8XBRI/AAAAAAAAAFI/G2gWJS0PPFofXyNf8JGl4TqgietoQqTngCLcBGAsYHQ/image.png"&gt;&lt;img alt="" src="https://res.cloudinary.com/practicaldev/image/fetch/s--y7dyavsN--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/-3uySrDeAnNU/YQtp_N8XBRI/AAAAAAAAAFI/G2gWJS0PPFofXyNf8JGl4TqgietoQqTngCLcBGAsYHQ/image.png"&gt;&lt;/a&gt;&lt;h3&gt;&lt;span&gt;2. Flex Grow&lt;/span&gt;&lt;/h3&gt;
&lt;span&gt;In this property,we can grow our flex boxes in a row to fill up the row completely if necessary. In other words, it defines how much space each flexbox should take up. For an example, we can make one out of 3 flex-boxes to grow even more longer. A perfect example would be the image below.&lt;/span&gt;&lt;span&gt;&lt;a href="https://lh3.googleusercontent.com/-WmwZe1VktwU/YQuhrQ2WssI/AAAAAAAAAFQ/zRvYnxbReDgO6C1rYV4P283nPy0NgEIFQCLcBGAsYHQ/image.png"&gt;&lt;img alt="" src="https://res.cloudinary.com/practicaldev/image/fetch/s--CYzPDPTq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/-WmwZe1VktwU/YQuhrQ2WssI/AAAAAAAAAFQ/zRvYnxbReDgO6C1rYV4P283nPy0NgEIFQCLcBGAsYHQ/image.png"&gt;&lt;/a&gt;Now that you understand the concept, you will need to add this block of code below to enable it in our CSS file.&lt;/span&gt;&lt;br&gt;


&lt;pre&gt;&lt;span&gt;div&lt;/span&gt;&lt;span&gt;:nth-of-type&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;1&lt;/span&gt;&lt;span&gt;)&lt;/span&gt; {flex&lt;span&gt;-&lt;/span&gt;grow&lt;span&gt;:&lt;/span&gt; &lt;span&gt;1&lt;/span&gt;;}&lt;br&gt;
&lt;span&gt;div&lt;/span&gt;&lt;span&gt;:nth-of-type&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;2&lt;/span&gt;&lt;span&gt;)&lt;/span&gt; {flex&lt;span&gt;-&lt;/span&gt;grow&lt;span&gt;:&lt;/span&gt; &lt;span&gt;3&lt;/span&gt;;}&lt;br&gt;
&lt;span&gt;div&lt;/span&gt;&lt;span&gt;:nth-of-type&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;3&lt;/span&gt;&lt;span&gt;)&lt;/span&gt; {flex&lt;span&gt;-&lt;/span&gt;grow&lt;span&gt;:&lt;/span&gt; &lt;span&gt;1&lt;/span&gt;;}&lt;br&gt;
&lt;/pre&gt;
&lt;br&gt;&lt;span&gt;If you set flex grow as 1, it will divide the spaces to be equal with the other boxes.&lt;/span&gt;&lt;h3&gt;&lt;span&gt;&lt;br&gt;&lt;/span&gt;&lt;/h3&gt;
&lt;h3&gt;&lt;span&gt;3. Flex Wrap&lt;/span&gt;&lt;/h3&gt;
&lt;span&gt;By default, flexbox will try it's best to fit into one tray/row/collumn. However, we can set extra flexboxes to move down/side into another tray by using the flex wrap property. The image below explains it even more. &lt;/span&gt;&lt;span&gt;&lt;a href="https://lh3.googleusercontent.com/-UvXIshOGJIE/YQukqgeV9mI/AAAAAAAAAFY/drtsNbV0TkAU7UOwmt8BCbLYhMskWRPmwCLcBGAsYHQ/image.png"&gt;&lt;img alt="" src="https://res.cloudinary.com/practicaldev/image/fetch/s--uK5yM9nI--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/-UvXIshOGJIE/YQukqgeV9mI/AAAAAAAAAFY/drtsNbV0TkAU7UOwmt8BCbLYhMskWRPmwCLcBGAsYHQ/image.png"&gt;&lt;/a&gt;Now, for this property, we will just add the following one-line code only. Do remember to remove the flex-grow property before testing this property.&lt;/span&gt;&lt;span&gt;&lt;br&gt;&lt;/span&gt;


&lt;pre&gt;&lt;span&gt;flex-wrap&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; &lt;span&gt;wrap&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;br&gt;
&lt;/pre&gt;
&lt;br&gt;&lt;h3&gt;&lt;span&gt;4. Flex-flow&lt;/span&gt;&lt;/h3&gt;
&lt;span&gt;In this property, the flex-direction and flex-box properties are combined together. The default value of this property is &lt;/span&gt;&lt;span&gt;row nowrap&lt;/span&gt;&lt;span&gt; . The image below is used for an example of &lt;/span&gt;&lt;span&gt;flex-flow: column wrap&lt;/span&gt;&lt;span&gt; .&lt;/span&gt;&lt;span&gt;&lt;a href="https://lh3.googleusercontent.com/-V-kMEwd9IRY/YQunyUn07hI/AAAAAAAAAFg/UXUVzhX1XfIgKLIFldEy_S6wR33UJt_igCLcBGAsYHQ/image.png"&gt;&lt;img alt="" src="https://res.cloudinary.com/practicaldev/image/fetch/s--OYYiUVIq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://lh3.googleusercontent.com/-V-kMEwd9IRY/YQunyUn07hI/AAAAAAAAAFg/UXUVzhX1XfIgKLIFldEy_S6wR33UJt_igCLcBGAsYHQ/image.png"&gt;&lt;/a&gt;The code would look like this:&lt;/span&gt;


&lt;pre&gt;&lt;span&gt;.flex-box&lt;/span&gt; {&lt;br&gt;
  &lt;span&gt;display&lt;/span&gt;&lt;span&gt;:&lt;/span&gt; flex;&lt;br&gt;
  flex&lt;span&gt;-&lt;/span&gt;flow&lt;span&gt;:&lt;/span&gt; column wrap;&lt;br&gt;
}&lt;br&gt;
&lt;/pre&gt;
&lt;br&gt;&lt;h3&gt;&lt;span&gt;5. Flex&lt;/span&gt;&lt;/h3&gt;
&lt;span&gt;Now that you have learned the 4 common properties, you will understand this property pretty well too. This property is a shorthand property (a easier line of code) to execute flexbox properties. By example, we can add the code of &lt;/span&gt;&lt;span&gt;flex: 1&lt;/span&gt;&lt;br&gt;&lt;h3&gt;&lt;span&gt;Browser Support&lt;/span&gt;&lt;/h3&gt;
&lt;span&gt;Now that you have learnt flexbox, you might feel like using it in all of your projects. However, flexbox is only supported in some browsers. Flexbox works in modern browsers but does not work in Internet Explorer 10 or earlier versions. Thus, you might want to keep that in mind. But besides that, I believe you should definetely try using flexbox.&lt;/span&gt;&lt;span&gt;&lt;br&gt;&lt;/span&gt;&lt;span&gt;This tutorial is just on the basics of flexbox. There are many more properties on flexbox. If you're interested for a part 2 of this tutorial, do comment down below or email me at &lt;span&gt;&lt;a href="mailto:codingporium@protonmail.com"&gt;codingporium@protonmail.com&lt;/a&gt;&lt;/span&gt;&lt;/span&gt;&lt;span&gt;&lt;br&gt;&lt;/span&gt;&lt;h3&gt;&lt;span&gt;Thank You!&lt;/span&gt;&lt;/h3&gt;
&lt;span&gt;If you have any doubts,uncertainties or suggestions, do comment down below or you can email me at &lt;span&gt;&lt;span&gt;&lt;a href="mailto:codingporium@protonmail.com"&gt;codingporium@protonmail.com&lt;/a&gt;&lt;/span&gt;&lt;/span&gt; . I hope this flexbox tutorial was useful for all of you and I would like to thank Code with Random for giving me the chance to write here. I hope to see you all in future posts. Goodbye!&lt;/span&gt;

</description>
      <category>css</category>
      <category>html</category>
      <category>flexbox</category>
    </item>
  </channel>
</rss>
