<?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: Param Aggarwal</title>
    <description>The latest articles on DEV Community by Param Aggarwal (@paramaggarwal).</description>
    <link>https://dev.to/paramaggarwal</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F66530%2F9d73124a-6199-4978-ac70-e9f0debcef04.jpg</url>
      <title>DEV Community: Param Aggarwal</title>
      <link>https://dev.to/paramaggarwal</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/paramaggarwal"/>
    <language>en</language>
    <item>
      <title>Build a Smart Grid Layout using Flexbox</title>
      <dc:creator>Param Aggarwal</dc:creator>
      <pubDate>Thu, 10 Jun 2021 01:33:17 +0000</pubDate>
      <link>https://dev.to/paramaggarwal/build-a-smart-grid-layout-using-flexbox-3nn1</link>
      <guid>https://dev.to/paramaggarwal/build-a-smart-grid-layout-using-flexbox-3nn1</guid>
      <description>&lt;p&gt;When laying out content inside our web or mobile app we need to ensure things are fluidly responsive and fill the screen. This requires that we have items that expand to take up the full width equally, but we also want these items to wrap into a new row when there are too many of them.&lt;/p&gt;

&lt;p&gt;This article assumes you are already familiar with the basics of Flexbox layout. To brush up, there is a great playground here: &lt;a href="https://flexbox.tech"&gt;https://flexbox.tech&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;We know that we need &lt;code&gt;flex-direction: row&lt;/code&gt; here to specify that the items should flow horizontally. We also know that we need &lt;code&gt;flex-wrap: wrap&lt;/code&gt; so that these items flow into a new row once they fill the width.&lt;/p&gt;

&lt;p&gt;But we also want these items to resize to fill the width that is available to them after reflowing.&lt;/p&gt;

&lt;p&gt;This is where &lt;code&gt;flex-basis&lt;/code&gt; comes in. The following screenshots will explain how this works.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;flex-basis: 20%&lt;/th&gt;
&lt;th&gt;flex-basis: 30%&lt;/th&gt;
&lt;th&gt;flex-basis: 40%&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--toOmdL9L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/a9gd8ah4sbt03ld0z1az.png" alt="Screenshot 2021-06-10 at 6.21.34 AM"&gt;&lt;/td&gt;
&lt;td&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yAmDtb_L--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/rj0ne7g2yxsbsuhqewgc.png" alt="Screenshot 2021-06-10 at 6.21.49 AM"&gt;&lt;/td&gt;
&lt;td&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--lu8fia2Q--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/04e07ppe8f5zijc9uw2y.png" alt="Screenshot 2021-06-10 at 6.21.59 AM"&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;(Note that this works on the web as well as in app with Yoga layout in React Native)&lt;/p&gt;

&lt;p&gt;This is how flex-basis is explained: flexBasis is an axis-independent way of providing the default size of an item along the main axis. Setting the flexBasis of a child is similar to setting the width of that child if its parent is a container with flexDirection: row or setting the height of a child if its parent is a container with flexDirection: column. The flexBasis of an item is the default size of that item, the size of the item before any flexGrow and flexShrink calculations are performed.&lt;/p&gt;

&lt;p&gt;You can try the full JSFiddle here: &lt;a href="https://jsfiddle.net/paramaggarwal/w37t0epy/1/"&gt;https://jsfiddle.net/paramaggarwal/w37t0epy/1/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
