<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Flexbox and Grid - Medium]]></title>
        <description><![CDATA[Want to master Flexbox or the CSS Grid? Get in Line! - Medium]]></description>
        <link>https://medium.com/flexbox-and-grids?source=rss----c59a61117d02---4</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Flexbox and Grid - Medium</title>
            <link>https://medium.com/flexbox-and-grids?source=rss----c59a61117d02---4</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 14 Nov 2026 13:24:28 GMT</lastBuildDate>
        <atom:link href="https://medium.com/feed/flexbox-and-grids" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Should You Learn the CSS Grid or Not ?]]></title>
            <link>https://medium.com/flexbox-and-grids/should-you-learn-the-css-grid-or-not-3e8c93a3619b?source=rss----c59a61117d02---4</link>
            <guid isPermaLink="false">https://medium.com/p/3e8c93a3619b</guid>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[responsive-design]]></category>
            <category><![CDATA[grid-layout]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[css-grid]]></category>
            <dc:creator><![CDATA[Ohans Emmanuel]]></dc:creator>
            <pubDate>Fri, 17 Nov 2017 03:07:16 GMT</pubDate>
            <atom:updated>2017-12-05T17:07:03.216Z</atom:updated>
            <content:encoded><![CDATA[<h4>A case for the past and present of CSS layouts.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*E5QX1CweZYFXXgAPCpZqKw.png" /></figure><p>There exists a wide amount of articles on the CSS Grid. I have written a lot of myself. It is no surprise that the CSS Grid has been the talk of the CSS community for sometime now.</p><p>Yeah, that’s pretty impressive. But let’s take a different approach to the CSS Grid and CSS layouts in general.</p><p>Ready?</p><p>Let’s go.</p><h3>How Did We Get Here?</h3><blockquote>A people without the knowledge of their past history, origin and culture is like a tree without roots — Marcus Garvey</blockquote><p>The CSS <em>Grid</em> layout (or perhaps, <em>Flexbox</em>) will feel like a shiny new toy if you do not know how we got to this point in the history of CSS layouts. Even if you did, you will appreciate the CSS Grid layout by taking a look at some of the problems it attempts to solve.</p><p>In a nutshell, a lot of things make sense with CSS, except for crafting intelligent CSS layouts. There were just so many layout hacks In the past. I took the liberty to explain this via a case study in ‘<em>How to Approach Layouts in 2017’</em></p><p><a href="https://medium.com/flexbox-and-grids/css-flexbox-grid-layout-how-to-approach-css-layouts-in-2017-and-beyond-685deef03e6c">How To Approach CSS layouts in 2017 — and beyond.</a></p><h3>So, Should You Use the CSS Grid ?</h3><p>The CSS Grid layout is brilliant — true. It is the future of layouts in CSS and it is not going away anytime soon — true.</p><p>Should you use it?</p><p>The simple answer “ <em>Yes, you should absolutely use the CSS Grid layout!”</em></p><p>The more involved answer is, <em>“Honestly, it may not 100% satisfy your demands on all projects right now</em>”</p><p>Someone once said to me, “<em>So for a big e-commerce site operating on a B2B level, where IE11 is the largest % of browsers, the modern CSS grid standard is useless and we have to fall back to older standards like flexbox</em>”</p><p>Well, maybe. A big ecommerce site may not be particular about building future proof layouts. If their users are mostly on IE11, they are likely to be happy just using Flexbox.</p><p>I get it.</p><p>The choice to use the CSS Grid layout must force you to answer some very serious questions.</p><p><em>“Should I start using the CSS Grid in production right now?”</em></p><p>“<em>Must I ?</em>”</p><p>Progressive enhancements? <em>“Well, that sounds good in theory. Does it work in real projects?”</em></p><h3>Using the CSS Grid layout moves the web forward</h3><p>I read an <a href="https://www.quora.com/Why-does-Apple-keep-getting-rid-of-things-instead-of-adding-them/answer/Brett-Bilbrey?share=baaad454&amp;srid=tLgv">answer</a> to why Apple keeps getting rid of things, instead of adding them</p><p>There, I learned this:</p><blockquote>“Supporting legacy is not always the best answer. Dropping things helps the industry move forward to adopt newer, better, formats.”</blockquote><p>In the same way, choosing to learn and use the CSS Grid advances the web. It helps the industry embrace newer and better formats. It helps us grow as a community. A community we so love, and want to grow.</p><p>Please be a part of this growth.</p><p>Where possible, invest in a decent CSS Grid education.You’ll be helping move the web forward.</p><p>Cheers :)</p><h3>Want to become Pro?</h3><p>Download my free CSS Grid cheat sheet, and also get two quality interactive Flexbox courses for free!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u2ew8JU87UuAmSYWY1y8Vg.png" /><figcaption><a href="http://eepurl.com/dcNiP1">Get the Free CSS Grid Cheat sheet + Two Quality Flexbox Courses for free!</a></figcaption></figure><p><a href="http://eepurl.com/dcNiP1">Get them now</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e8c93a3619b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flexbox-and-grids/should-you-learn-the-css-grid-or-not-3e8c93a3619b">Should You Learn the CSS Grid or Not ?</a> was originally published in <a href="https://medium.com/flexbox-and-grids">Flexbox and Grid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Write for Us]]></title>
            <link>https://medium.com/flexbox-and-grids/write-for-us-62bf92dcd369?source=rss----c59a61117d02---4</link>
            <guid isPermaLink="false">https://medium.com/p/62bf92dcd369</guid>
            <category><![CDATA[writing]]></category>
            <dc:creator><![CDATA[Ohans Emmanuel]]></dc:creator>
            <pubDate>Fri, 04 Aug 2017 11:34:35 GMT</pubDate>
            <atom:updated>2017-08-04T11:37:23.357Z</atom:updated>
            <content:encoded><![CDATA[<h4>We want you, Yes you.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gZMCa8_bNSHxA5pJusdn5g.png" /></figure><h4>My 3 seconds Pitch</h4><p>Hey 👋</p><p>I began writing the articles for the Flexbox and Grid publication about 3 months ago.</p><p>It’s been an amazing ‘experiment’.</p><p>I enjoy it, and have been delighted to see some of the articles get quite popular.</p><h4>Why make it open?</h4><p>I woke up this morning, bounced the idea off of a couple friends, and decided it’d be amazing to have other bright minds contribute to the publication.</p><h4>How ?</h4><ol><li>Write a draft here on medium</li><li>Send me a link at ohansemmanuel at gmail dot com</li><li>I’ll take a look 👀</li><li>I’ll request the article to be added to the publication</li><li>Hit the publish button 👇</li></ol><p>Uh, what next? Go and write a draft. I’ll wait 🌝</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=62bf92dcd369" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flexbox-and-grids/write-for-us-62bf92dcd369">Write for Us</a> was originally published in <a href="https://medium.com/flexbox-and-grids">Flexbox and Grid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Free Flexbox Courses]]></title>
            <link>https://medium.com/flexbox-and-grids/free-courses-49ce873bfa75?source=rss----c59a61117d02---4</link>
            <guid isPermaLink="false">https://medium.com/p/49ce873bfa75</guid>
            <category><![CDATA[flexbox]]></category>
            <dc:creator><![CDATA[Ohans Emmanuel]]></dc:creator>
            <pubDate>Thu, 03 Aug 2017 22:53:53 GMT</pubDate>
            <atom:updated>2017-08-30T14:47:21.101Z</atom:updated>
            <content:encoded><![CDATA[<h4>Free, Quality and Interactive Flexbox Online Courses.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/940/1*ZE0l3sMeXr_IM0kiHrgHkQ.png" /></figure><p>Here are a couple courses (mostly interactive) from me:</p><h3><a href="https://www.educative.io/collection/5191711974227968/5741031244955648?authorName=Ohans%20Emmanuel">1. Understanding Flexbox: Everything you need to know</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*94v7Z8HcvCufukl--HT4PQ.jpeg" /></figure><h3><a href="https://www.educative.io/page/5191711974227968/5754903989321728?authorName=Ohans%20Emmanuel">2. The 4 (Practical) Flexbox Tricks you Need to Know</a></h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RlzWvYWV3t_YyhHaon7YpA.jpeg" /></figure><h4><strong><em>NB: This article will be updated frequently.</em></strong></h4><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49ce873bfa75" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flexbox-and-grids/free-courses-49ce873bfa75">Free Flexbox Courses</a> was originally published in <a href="https://medium.com/flexbox-and-grids">Flexbox and Grid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What You Didn’t know about the CSS Fractional Unit]]></title>
            <link>https://medium.com/flexbox-and-grids/what-you-didnt-know-about-the-css-fractional-unit-580bd62647e8?source=rss----c59a61117d02---4</link>
            <guid isPermaLink="false">https://medium.com/p/580bd62647e8</guid>
            <category><![CDATA[flexbox]]></category>
            <category><![CDATA[responsive-design]]></category>
            <category><![CDATA[grid-layout]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[grid]]></category>
            <dc:creator><![CDATA[Ohans Emmanuel]]></dc:creator>
            <pubDate>Wed, 19 Jul 2017 20:20:06 GMT</pubDate>
            <atom:updated>2017-12-05T17:15:38.719Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*l1PakVrT356Ys4AR8odTJg.jpeg" /><figcaption>What You Didn’t know about the CSS Fractional Unit</figcaption></figure><h3>Introduction</h3><p>The fractional unit (fr) is a new form of unit measurement in CSS — largely associated with the CSS Grid.</p><p>If you are not familiar with the CSS Fractional unit(fr), be sure to check out my dead simple <a href="https://medium.com/flexbox-and-grids/the-css-fractional-unit-fr-in-approachable-plain-language-fdc47bd387f7">introductory article</a>.</p><h3>What you didn’t know</h3><p>In the most basic form, the declaration for the fractional unit may look like this:</p><pre>grid-template-rows: 1fr 1fr 1fr</pre><p>At the heart of the fractional unit is fractions 1.e the division of the available space in fractions. But is there more than meets the eye?</p><p>I love Examples. Who doesn’t?</p><p>Consider the image below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZCYhmJ4xOPk-oJEAhlBlog.png" /><figcaption><a href="https://codepen.io/ohansemmanuel/pen/XgyGVE">https://codepen.io/ohansemmanuel/pen/XgyGVE</a></figcaption></figure><p>The image represents a typical 2 column layout. A sidebar on the left, and a main content area on the right. The sidebar has a fixed width and the main content area expands to fill the remaining available space.</p><p>This simple layout may be written out in a few lines of code. Something along these lines:</p><pre>grid-template-columns: 150px 1fr;</pre><p>The 150px represents the fixed width of the sidebar and 1fr allows for the main content section to fill the remaining available space.</p><p>Thanks to the CSS Grid and fr unit, that is done.</p><p>Assume that the overall container of the grid container had a minimum width. Do you think that would affect the layout in any way?</p><p>Think for a bit. I’ll wait.</p><p>In terms of code, here is what I mean. Where .grid represent a grid container:</p><pre>.grid {<br>  min-width: 400px;<br>}</pre><p>The simple answer to my question is a resounding ‘Yes!. But how exactly is the layout affected?</p><blockquote>1. The fr unit fills up the available space BUT it is NEVER smaller than the minimum size of the grid container</blockquote><p>In a more visual form, here it is:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kJ0bCqdFF_jhP4s-haAGrg.gif" /><figcaption>A GIF. Pen here: s<a href="https://codepen.io/ohansemmanuel/pen/XgyGVE">https://codepen.io/ohansemmanuel/pen/XgyGVE</a></figcaption></figure><p>As the page is being resized, the fr unit will always fill the remaining available screen — hence, responsive. However it will never be lesser than the minimum width of the container.</p><p>In the example above, the main section will keep being responsive UNTIL it reaches a width of 400p ,the min-width of the grid container. At this point, the main section remains fixed. Not responsive.</p><p>Now, this does not end with setting a minimum width.</p><p>This has covered one scenario. Let’s see another.</p><p>What if an image was added within the main section?</p><pre>&lt;main&gt;<br>    &lt;img src=&quot;<a href="http://image.prntscr.com/image/f2b0ac9e43334eddac9c1af05e573888.png">some-image.png</a>&quot;/&gt;<br>&lt;/main&gt;</pre><p>Could this have any effect on the layout?</p><p>Well it depends. This leads to the second point.</p><blockquote>2. The fr unit fills up the available space BUT it is NEVER smaller than the content of the row or column</blockquote><p>Adding an image within the main section, you get this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bwFsvycyF6C_YUDtMmnywA.png" /><figcaption><a href="https://codepen.io/ohansemmanuel/pen/XgyGVE">https://codepen.io/ohansemmanuel/pen/XgyGVE</a></figcaption></figure><p>When you resize the page, the main section will NOT go below the set width of the image.</p><p>The width of the image in this example is about 430px. You may see this in action below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*7G_0phdmuw7e5qBa22xTUg.gif" /><figcaption>A GIF. Pen here: s<a href="https://codepen.io/ohansemmanuel/pen/XgyGVE">https://codepen.io/ohansemmanuel/pen/XgyGVE</a></figcaption></figure><p>As shown in the image above, the main section declared with 1fr never goes below the of the content of the row. The image above shows the horizontal scrollbars. The bars are present in a bid to accomodate the fixed main section.</p><p>This is beautiful. Later in the article I talk about how all this knowledge is useful.</p><p>However, there’s one more scenario to look at.</p><h3>What if there’s a conflict in declaration?</h3><p>What if for some reason you have a min-width set on the grid container, and yet have some content in the row?</p><pre>.grid {<br>  min-width: 400px;<br>}</pre><pre>.grid img {<br>  width: 600px;<br>}</pre><blockquote>3. In the case of a conflict, the fr unit is NEVER smaller than than the maximum of the container’s minimum width or the row/column content size.</blockquote><p>In the example above, even though the grid container has a minimum width of 400px the main section will never be smaller than the width of the image, 600px</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*MZJg0vU9aZu9P5p8giUt4w.gif" /></figure><p>I have created a <a href="https://codepen.io/ohansemmanuel/pen/XgyGVE">codepen</a> for which you may interact with all the points stated here: <a href="https://codepen.io/ohansemmanuel/pen/XgyGVE">https://codepen.io/ohansemmanuel/pen/XgyGVE</a></p><h3>How can this knowledge profit you?</h3><h4>1. Knowing the Fundamentals</h4><p>At the time of this writing, the CSS Grid layout is relatively new. By implication, if you get stuck while using the CSS Grid, there may NOT be sufficient stackoverflow answers to run to :-)</p><p>Understanding how things work under the hood saves you a lot of wasted debugging time.</p><h4>2. Bloated Code</h4><p>In cases where you may have had to explicitly use the minmax function, you may need to rethink if it is necessary. The fr unit can pick out minimums intuitively. At least, you now know how that works now.</p><h4>3. Weird Horizontal scrollers</h4><p>If you have weird horizontal scrollers where you expect the grid to be responsive, check what’s going on with the fr declarations. You may have a fix here.</p><h3>Want to become Pro?</h3><p>Download my free CSS Grid cheat sheet, and also get two quality interactive Flexbox courses for free!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u2ew8JU87UuAmSYWY1y8Vg.png" /><figcaption><a href="http://eepurl.com/dcNiP1">Get the Free CSS Grid Cheat sheet + Two Quality Flexbox Courses for free!</a></figcaption></figure><p><a href="http://eepurl.com/dcNiP1">Get them now</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=580bd62647e8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flexbox-and-grids/what-you-didnt-know-about-the-css-fractional-unit-580bd62647e8">What You Didn’t know about the CSS Fractional Unit</a> was originally published in <a href="https://medium.com/flexbox-and-grids">Flexbox and Grid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Most Popular Navigation Bars created with Flexbox]]></title>
            <link>https://medium.com/flexbox-and-grids/the-most-popular-navigation-bars-created-with-flexbox-6c0f59f55686?source=rss----c59a61117d02---4</link>
            <guid isPermaLink="false">https://medium.com/p/6c0f59f55686</guid>
            <category><![CDATA[flexbox]]></category>
            <category><![CDATA[grid]]></category>
            <category><![CDATA[grid-layout]]></category>
            <category><![CDATA[responsive-design]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Ohans Emmanuel]]></dc:creator>
            <pubDate>Sat, 15 Jul 2017 08:08:57 GMT</pubDate>
            <atom:updated>2017-12-05T17:16:23.873Z</atom:updated>
            <content:encoded><![CDATA[<p>This is a simple but practical article. The aim is to build the navigation bars for facebook twitter github and medium with Flexbox. Facebook and Twitter are <em>arguably</em> the most popular websites in the world. Hence, the most popular navigation bars in the world :-)</p><h3>Getting Started</h3><p>The first step is to create some sort of container to house the navigation bars we will be making. When done, it should look like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mI9f-FKx873a0C9-GB3pbg.png" /><figcaption>first step.</figcaption></figure><p>Let’s get started.</p><p>First, create a basic html document to house the navigation bars.</p><pre>&lt;main&gt;<br>  &lt;nav class=&quot;twitter&quot;&gt;Twitter&lt;/nav&gt;<br>  &lt;nav class=&quot;facebook&quot;&gt;Facebook&lt;/nav&gt;<br>  &lt;nav class=&quot;gitHub&quot;&gt;Github&lt;/nav&gt;<br>  &lt;nav class=&quot;medium&quot;&gt;Medium&lt;/nav&gt;<br>&lt;/main&gt;</pre><p>Pretty simple. A main section to act as the container. The navigation bars will seat within their respective containers too.</p><p>Let’s add a bit of styling.</p><p>To keep the main section in the center of the page, do this:</p><pre>body {<br>  display: flex;<br>  justify-content: center;<br>  align-items: center;<br>  min-height: 100vh;<br>}</pre><p>Also, give main section a bit of style. No one loves ugly designs. Aaargh!</p><pre>main {<br>    min-height: 400px;<br>    min-width: 400px;<br>    background: #fff;<br>    padding: 40px 20px;<br>    border-radius: 5px;<br>    box-shadow: 5px 55px 50px -20px #b6b6b6; <br>}</pre><p>And here’s what we have:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mI9f-FKx873a0C9-GB3pbg.png" /><figcaption>current state of things.</figcaption></figure><p>Yeah! Now we’ve got something on the screen.</p><h3>Twitter</h3><p>Let’s start creating the first navigation bar, twitter!</p><p>Why Twitter first? Not Facebook? I have no <em>legit</em> reason. I just feel like :-) Or maybe because I haven’t used facebook in a long time!</p><p>The official Twitter navigation bar looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ee3E8KXhByCdnzJuAx3sOw.png" /></figure><p>Let’s structure the html document for glory!</p><p>So, if I read your thoughts, this is how you think we’ll structure the document, right? Three div of some sort?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CSQ610cyQCXghQ6S8Jv7Vg.png" /><figcaption>if you were gong to use `floats`</figcaption></figure><p>Hell no!</p><p>For simplicity, and to really take control of some flexbox goodies, I’ll use an unordered list ul. This means the nav tags will be changed to ul tags.</p><pre>&lt;ul class=&quot;twitter&quot; role=&quot;navigation&quot;&gt;<br>    &lt;li&gt;&lt;/li&gt;<br>    &lt;li&gt;&lt;/li&gt;<br>    &lt;li&gt;&lt;/li&gt;<br>    &lt;li&gt;&lt;/li&gt;<br>    &lt;li&gt;&lt;/li&gt;<br>    &lt;li&gt;&lt;/li&gt;<br>    &lt;li&gt;&lt;/li&gt;<br> &lt;/ul&gt;</pre><p>A list item li for each element within the navigation bar. I have gone ahead to add role=navigation for accesibility.</p><p>Flesh out the basic markup, like this:</p><pre>&lt;ul class=&quot;twitter&quot; role=&quot;navigation&quot;&gt;<br>    &lt;li&gt;&lt;i class=&quot;fa fa-home&quot;&gt;&lt;/i&gt;Home&lt;/li&gt;<br>    &lt;li&gt;&lt;i class=&quot;fa fa-bell-o&quot;&gt;&lt;/i&gt;Notifications&lt;/li&gt;<br>    &lt;li&gt;&lt;i class=&quot;fa fa-envelope-o&quot;&gt;&lt;/i&gt;Messages&lt;/li&gt;<br>    &lt;li&gt;&lt;i class=&quot;fa fa-twitter&quot;&gt;&lt;/i&gt;&lt;/li&gt;<br>    &lt;li&gt;&lt;form&gt;&lt;input placeholder=&quot;search twitter&quot;/&gt;&lt;i class=&quot;fa fa-search&quot;&gt;&lt;/i&gt;&lt;/form&gt;&lt;/li&gt;<br>    &lt;li&gt;&lt;i class=&quot;fa fa-user-circle-o&quot;&gt;&lt;/i&gt;&lt;/li&gt;<br>    &lt;li&gt;&lt;button&gt;tweet&lt;/button&gt;&lt;/li&gt;<br>  &lt;/ul&gt;</pre><p>I know it looks complex, but it is a very simple document. A bunch of li tags with icons in i tags. These icons are got from <a href="http://fontawesome.io/">font awesome</a>. This will save us a lot of stress, and keep these examples simple.</p><p>At this point this is what you should have:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IGEkXLNLrFrviV88qBsiaA.png" /><figcaption>basic setup for twitter.</figcaption></figure><p>I have gone ahead to increase the width of the main section.</p><pre>main {<br>   width: 70%<br>}</pre><p>Now we can move on to some CSS goodness 😄</p><p>Clear the unneccessary spacing and list style from the unonderlist list:</p><pre>ul {<br>  padding: 0;<br>  list-style: none;<br>}</pre><p>Now, the twitter navigation should seat on the same line as the rest of the contents in the container. Oh, and without the ugly list dots too.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x_Gqb2buln3KEYw-UqKcNw.png" /><figcaption>after removing the undue spacing and list style.</figcaption></figure><p>Now, let’s get Flexbox unto the scene. Aye! Been waiting for this:</p><pre>.twitter {<br>  display: flex;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HpWOEv86rblrbFznqENNtQ.png" /><figcaption>The flexbox magic!</figcaption></figure><p>The sweet spot of this particular navigation comes next. How do you make sure the twitter bird (or whatever it is called) stays at the center?</p><p>Use Flexbox!</p><p>Target the list item containing the twitter bird. This is because the list li represents the flex-item</p><p>Give it a class so we can make reference to it via CSS.</p><pre>&lt;li class=&quot;twitter__bird&quot;&gt; ... &lt;/li&gt;</pre><p>Now make magic!</p><pre>.twitter__bird {<br>  margin-left: auto;<br>  margin-right: auto<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PPygwx2-Xg3pkIUqt6IHLw.png" /><figcaption>That’s it!</figcaption></figure><p>Believe me, that is all the Flexbox you need. 3 lines of Flexbox!</p><p>If you aren’t familiar with the flexbox auto margin trick, i wrote an article that explains everything you need to know <a href="https://github.com/ohansemmanuel/Understanding-Flexbox/blob/master/05.%20Auto%20margin%20alignment/auto_margin.md">here</a>.</p><p>If you clean up the UI a bit, you’ll have the navigation looking good. Just like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lTdzS5g-XBAkxQw8e5vFxg.gif" /><figcaption>good looking, huh?</figcaption></figure><p>If you spend a lot more on styling the navigation bar, you will have it looking better.</p><p>Here’s the bit of “extra” styling I wrote:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/2aac94c7379a10809e97263e816e2c69/href">https://medium.com/media/2aac94c7379a10809e97263e816e2c69/href</a></iframe><h3>Facebook</h3><p>Now let’s create the Facebook navigation bar. Let’s make Zuck happy.</p><p>The official navigation bar looks like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zT_giJ1jU6hFjS7HQ7QyDQ.png" /><figcaption>facebbok navigation bar</figcaption></figure><p>As always, start with a basic html document. An unordered list with a couple list elements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MEvvts1UwEvGj0j8a8lQ3A.png" /><figcaption>basic setup for the facebook navigation bar. Becasue I copied and pasted (who doesn’t?) the input field reads, “search twitter” instead of “seach facebook”</figcaption></figure><p>Here is all the code at this point:</p><pre>&lt;ul class=&quot;facebook&quot; role=&quot;navigation&quot;&gt;<br>    &lt;li class=&quot;facebook__brand&quot;&gt;&lt;i class=&quot;fa fa-facebook-official&quot;&gt;&lt;/i&gt;&lt;/li&gt;  <br>    &lt;li class=&quot;facebook__search&quot;&gt;&lt;form&gt;&lt;input placeholder=&quot;search Facebook&quot;/&gt;&lt;i class=&quot;fa fa-search&quot;&gt;&lt;/i&gt;&lt;/form&gt;&lt;/li&gt;<br>    &lt;li&gt;&lt;i class=&quot;fa fa-user-circle-o&quot;&gt;&lt;/i&gt;&lt;/li&gt;<br>    &lt;li&gt;&lt;i class=&quot;fa fa-bell-o&quot;&gt;&lt;/i&gt;Notifications&lt;/li&gt;<br>    &lt;li&gt;Home&lt;/li&gt;<br>    &lt;li&gt;&lt;i class=&quot;fa fa-user-circle-o&quot;&gt;&lt;/i&gt; Ohans&lt;/li&gt;<br>    &lt;li&gt;&lt;i class=&quot;fa fa-caret-down&quot;&gt;&lt;/i&gt;&lt;/li&gt; <br>&lt;/ul&gt;</pre><p>Let’s style this.</p><p>As always, It all begins with a one liner:</p><pre>.facebook {<br>  display: flex<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fYVdaTlo9XG627DroTjTww.png" /><figcaption>flexbox initiated for the facebook navigation.</figcaption></figure><p>Target the facebook search form and get flexbox in action.</p><pre>.facebook__search {<br>  margin-right: auto;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pmz3UT6er_jrJOwIVoqfbA.png" /><figcaption>flexbox in action</figcaption></figure><p>Haha. That my dear is all the flexbox you need!</p><p>If you spend some more time, the UI will be polished. Something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bBWvhNyPFZs_OtDJEUPxFA.png" /><figcaption>facebook navigation done. <a href="https://codepen.io/ohansemmanuel/full/KqEeor/">https://codepen.io/ohansemmanuel/full/KqEeor/</a></figcaption></figure><p>Here is all the “extra” styling I wrote:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/303d20af2d0f5f23fe5526a5063305dc/href">https://medium.com/media/303d20af2d0f5f23fe5526a5063305dc/href</a></iframe><h3>Exercise</h3><p>The entire code lives here: <a href="https://codepen.io/ohansemmanuel/full/KqEeor/">https://codepen.io/ohansemmanuel/full/KqEeor/</a></p><p>If you want to practice the concepts learned, I advice you try to build the navigation bars for Medium and Github. You’ll find it interesting.</p><h3>Conclusion</h3><p>I have been learning Spanish! So, I’ll say “thank you very much” in spanish</p><blockquote>— <em>muchas gracias</em></blockquote><p>Thanks for following along.</p><h3>Want to become Pro?</h3><p>Download my free CSS Grid cheat sheet, and also get two quality interactive Flexbox courses for free!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u2ew8JU87UuAmSYWY1y8Vg.png" /><figcaption><a href="http://eepurl.com/dcNiP1">Get the Free CSS Grid Cheat sheet + Two Quality Flexbox Courses for free!</a></figcaption></figure><p><a href="http://eepurl.com/dcNiP1">Get them now</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6c0f59f55686" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flexbox-and-grids/the-most-popular-navigation-bars-created-with-flexbox-6c0f59f55686">The Most Popular Navigation Bars created with Flexbox</a> was originally published in <a href="https://medium.com/flexbox-and-grids">Flexbox and Grid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[If you Love ReactJS, You’ll Love the CSS Grid]]></title>
            <link>https://medium.com/flexbox-and-grids/if-you-love-reactjs-youll-love-the-css-grid-52933e0d61ac?source=rss----c59a61117d02---4</link>
            <guid isPermaLink="false">https://medium.com/p/52933e0d61ac</guid>
            <category><![CDATA[react]]></category>
            <category><![CDATA[css-grid]]></category>
            <category><![CDATA[responsive-web-design]]></category>
            <category><![CDATA[flexbox]]></category>
            <category><![CDATA[responsive-design]]></category>
            <dc:creator><![CDATA[Ohans Emmanuel]]></dc:creator>
            <pubDate>Tue, 11 Jul 2017 21:40:29 GMT</pubDate>
            <atom:updated>2017-12-05T17:17:09.486Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HlBSACT5fsxhcgMFLT31Wg.png" /><figcaption>I hastily made this ugly graphic :-)</figcaption></figure><h4>Here’s why you will.</h4><p>React took the frontend community by storm. I use ReactJS everyday, literarily.</p><p>When you get a hang of React, It becomes painless to create interactive UIs. You’re also able to design simple views for each state in your application, and React will efficiently update and render just the right components when your data changes. Amazing!</p><p>What is even more interesting is the declarative APIs React offers. This is one of React’s sweet spots.</p><p>Why declarative? Declarative views make your code more predictable and easier to debug. It really does.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/894/1*MLkabD4-cKJm50o5Y7yi6g.png" /><figcaption>the official React documentation.</figcaption></figure><h4>So, where does the CSS Grid come In?</h4><p>The CSS Grid layout has been getting a lot of attention of late — and for good reason!</p><p>Just like React, it makes creating complex, 2 dimensional layouts easy. If you think creating layouts with CSS is crap or unintelligent, give the CSS Grid a try.</p><p>In one of the examples in the official <a href="https://www.w3.org/TR/css-grid-1/">css grid specification</a>, i found this:</p><blockquote>…an author might achieve all the sizing, placement, and alignment rules <strong>declaratively</strong>.</blockquote><p>Yeah, it is declarative!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/933/1*42E2QtypEfccqXqb640jMw.png" /><figcaption>from the CSS Grid Spec.</figcaption></figure><p>As websites evolved from simple documents into complex, interactive applications, web layouts became difficult to compose. The CSS Grid has come to our rescue.</p><p>My sincere advice is, get a decent CSS <a href="https://medium.com/flexbox-and-grids/how-to-efficiently-master-the-css-grid-in-a-jiffy-585d0c213577">Grid education</a> ASAP.</p><p>And don’t be scared of using it in production. <a href="https://medium.com/u/be9c04b39015">Rachel Andrew</a> wrote an <a href="https://www.rachelandrew.co.uk/archives/2017/07/04/is-it-really-safe-to-start-using-css-grid-layout/?utm_campaign=CSS%2BLayout%2BNews&amp;utm_medium=email&amp;utm_source=CSS_Layout_News_102">amazing piece</a> on that too.</p><p>If you find the CSS Grid interesting to work with, <a href="https://twitter.com/OhansEmmanuel">tweet me</a>. Even if you don’t, I may still be able to help 😄</p><h3>Want to become Pro?</h3><p>Download my free CSS Grid cheat sheet, and also get two quality interactive Flexbox courses for free!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u2ew8JU87UuAmSYWY1y8Vg.png" /><figcaption><a href="http://eepurl.com/dcNiP1">Get the Free CSS Grid Cheat sheet + Two Quality Flexbox Courses for free!</a></figcaption></figure><p><a href="http://eepurl.com/dcNiP1">Get them now</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=52933e0d61ac" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flexbox-and-grids/if-you-love-reactjs-youll-love-the-css-grid-52933e0d61ac">If you Love ReactJS, You’ll Love the CSS Grid</a> was originally published in <a href="https://medium.com/flexbox-and-grids">Flexbox and Grid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Efficiently Master the CSS Grid — in a Jiffy]]></title>
            <link>https://medium.com/flexbox-and-grids/how-to-efficiently-master-the-css-grid-in-a-jiffy-585d0c213577?source=rss----c59a61117d02---4</link>
            <guid isPermaLink="false">https://medium.com/p/585d0c213577</guid>
            <category><![CDATA[grid-layout]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[flexbox]]></category>
            <category><![CDATA[responsive-design]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Ohans Emmanuel]]></dc:creator>
            <pubDate>Fri, 07 Jul 2017 07:28:16 GMT</pubDate>
            <atom:updated>2018-06-26T20:56:21.279Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ewoge0tZmHZ1nWd-UDBMbg.png" /><figcaption>How to Efficiently Master the CSS Grid in a Jiffy</figcaption></figure><h4>Learn the 20% you need for 80% efficiency with CSS Grid.</h4><h3>Introduction</h3><p>This is NOT the article to learn “everything” about the css grid.</p><p>On the contrary, the target audience is people who want results quickly, and be productive while at it.</p><p>In the four parts of this article, I will show you the 20% you need for 80% efficiency with the CSS Grid layout.</p><p>Let’s dig in!</p><h3>Why just 20%?</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LPf5rSOWKaSKTOUwkqfK0w.png" /></figure><p>Where possible, a programmer seeks efficiency — the supposed lazy way out.</p><p>The CSS Grid layout is complex. In my opinion, more complex than Flexbox. <em>(mehn, it took me weeks to figure out flexbox)</em><br>Not so because it is “difficult” but the CSS Grid has 18 new properties plus other concepts you’ve never heard of anywhere else in CSS.</p><p>So, do you need all of these new properties now? Right now?</p><p>No, you don’t!</p><p>Just learn the bit to get you results now. You can go ahead to learn the other properties later. This is my definition of “efficiency with the CSS Grid layout”</p><h3>1. What is the CSS Grid Layout ?</h3><p>If you’re new to layouts in CSS, the CSS Grid layout may seem strange to you.</p><p>Have you heard of Flexbox?</p><p>I like to view the CSS Grid layout as an older sibling (or parent) of Flexbox.</p><p>Handling Layouts in CSS have been difficult and crappy. Flexbox brought a bit of fresh air — but the CSS Grid is even better.</p><h3>What we’ll Build.</h3><p>You will learn to apply your 20% knowledge to building a clone of a responsive music app layout.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ripUP4LuXPQ851Zlq79bWQ.gif" /><figcaption>a responsive music app, catty music</figcaption></figure><h3>Part 1: The 10% you Need to Know — Basic Terminologies</h3><p>Let’s take a look at the first things you absolutely have to know.</p><h4>What is a Grid Container?</h4><p>Every website, or application layout you make (or have seen) is essentially, boxes placed within certain defined boundaries.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*uFGh3Vo2i9MneYvjqJNhRw.gif" /><figcaption>gif by <a href="https://dribbble.com/bnistr">chris bannister</a></figcaption></figure><p>In very simple terms, a grid is just “lines”. Horizontal and vertical lines that define the placement of other design elements.</p><p>You’ll be familiar with this if you use design software such as adobe photoshop or sketch.</p><p>In the context of the CSS Grid layout, A Grid container is the parent that contains all the items in the grid. The Grid container defines the initial placement of the grid lines, both vertical and horizontal.</p><h4>What is a Grid Line?</h4><p>Assume for a bit that you have a fully laid out grid like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xcID2GAZoYqhb4LYjN6Qug.png" /><figcaption>supposed grid layout</figcaption></figure><p>The layout comprises a grid container with a number of perfectly laid out grid items (children elements within the grid)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9K74dULhLERm5_3a37Byqw.png" /><figcaption>a bit of explanation</figcaption></figure><p>Grid lines are the horizontal and vertical lines that divide the grid.</p><h4>What is a Grid Cell?</h4><p>A Grid cell is the smallest unit of area in a grid layout. It is any space bounded by four grid lines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7X_NTZG0ikpVwsaB0qfdAw.png" /><figcaption>The “small boxes” of grid items may be referred to as grid cells.</figcaption></figure><h4>Grid Area</h4><p>A grid area may be as small as the area contained within a grid cell (shown above). It may also be as large as all the cells within the grid.</p><p>In the image below, the area covered by the four cells is a grid area.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_4ZnWO3zlt82VMHQ_3VNXA.png" /></figure><h4>What is a Grid Track</h4><p>I don’t like very technical definitions. So, a grid track may be seen as a fancy name for columns and (or) rows. It is the space between any two grid lines.</p><p>The image below show example grid tracks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oan28239S-v0oJZECQPKIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-tby4L7UaQavuy6uc0H1LQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xkbT0CjkBWb-5S_hxcBvGw.png" /><figcaption>grid tracks</figcaption></figure><p>So, we’ve got the first part sorted out.</p><h3>Part 2: The “Other” 10% you Need to Know — CSS Grid, Baby steps.</h3><p>Now that you understand the basic terminologies, like an adventurous kid, let’s get kicking!</p><h4>How do you Define a Grid?</h4><p>Just like Flexbox, everything begins with a one-liner. display: grid or display:inline-grid for an inline version.</p><p>For example, to make a certain div a grid container, do this:</p><pre>div {<br>  display: grid;<br>}</pre><h4>How do You Create Columns and Rows?</h4><p>A grid without columns and rows is kinda pointless. To create columns and rows within a grid container, you use these two new css properties: grid-template-columns and grid-template-rows.</p><p>So how do you use these? Pretty simple.</p><p>grid-template-columns defines the placement of the columns. grid-template-rows defines the placement of the rows.</p><p>You pass in length values into these properties, and they create row and column tracks within the grid container.</p><p>See an example:</p><p>grid-template-columns: 100px 200px 300px</p><p>This will create 3 new columns within the grid container. The first with a length of 100px, the other, 200px and the last, 300px.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OGJmxXekTwSlW-aoTeSXEw.png" /><figcaption>grid-template-columns: 100px 200px 300px</figcaption></figure><p>grid-template-rows: 100px 200px 300px</p><p>This will create 3 new rows within the grid container. The extents are shown below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TcGMy7iMxXoRbqs8hL0NHw.png" /><figcaption>grid-template-rows: 100px 200px 300px</figcaption></figure><p>Now put these together, and you get a full grid — with rows and column defined.</p><pre>grid-template-columns: 100px 200px 300px<br>grid-template-rows: 100px 200px 300px</pre><h3>Part 3: Time to Code — CSS Grid, Hands-on</h3><p>Now let’s take baby steps to building a clone of the famous music app, catty music 😁</p><p>For speedy development, I would be using <a href="http://www.codepen.io/">Codepen</a>. Spin up a new project, and let’s get cracking.</p><h3>How to Create the Basic Grid Setup for Catty Music</h3><p>I believe you have a basic codepen project up and running now.</p><p>We will kick off with a very basic html document.</p><pre>&lt;body&gt;<br>   &lt;aside&gt;&lt;/aside&gt;<br>   &lt;main&gt;&lt;/main&gt;<br>   &lt;footer&gt;&lt;/footer&gt;<br>&lt;/body&gt;</pre><p>There’s a bit of foresight involved in choosing this structure. You’ll understand very soon.</p><p>Now style the document.</p><pre>body {<br>   display: grid;<br>   min-height: 100%<br>}</pre><p>This will kick off the grid formatting context by making the body a grid-container</p><p>Now we can go on to define the rows and columns structure within the grid.</p><h3>How to create the Rows and Columns for Catty Music</h3><p>Creating the rows and columns is pretty easy.</p><p>The final design we are gunning for is this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VFkE679czY0Tb49R9GNvyg.png" /><figcaption>final layout we seek.</figcaption></figure><p>However, the initial grid setup we need is a grid of 2 rows and 2 columns.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*80Qn4c32kqbQzMVh-AcAoQ.png" /><figcaption>initial grid setup</figcaption></figure><h4>Here are a few things to note about this Grid setup</h4><p><strong>Columns:</strong></p><ol><li>The first column must have a fixed width — say, 50px</li><li>The second column must fill the remaining width in the grid.</li></ol><p><strong>Rows:</strong></p><p>3. The second row must have a fixed height — say, 100px</p><p>4. The first row must also fill the remaining height within the grid.</p><h4>The lay-man’s solution.</h4><p>If you’re NOT very experienced with CSS, you’re likely to write this:</p><pre>body {<br>   ...   <br>   grid-template-rows: 100% 100px;<br>   grid-template-columns: 50px 100%;<br>}</pre><p>The problem with this is that you have accidentally created a grid whose width and height is a total of 100% + 50px / 100% + 100px</p><p>We want a total width and height of exactly 100% So this approach is wrong.</p><h4>The “smart ” person’s solution.</h4><p>If you’ve got some experience with CSS under your belt, then you’re likely to do something much more smarter. Like this:</p><pre>body {<br>   ...<br>   grid-template-rows: calc(100% - 100px) 100px;<br>   grid-template-columns: 50px calc(100%-50px)</pre><p>This is pretty smart. But it’s got one problem — it isn’t very maintainable.</p><p>For example, If for some reasons you have to change any of the the fixed widths, then you must always change the calc definition.</p><h4>The efficient Solution</h4><p>Luckily, CSS Grid has a new unit that solves our problem elegantly. <a href="https://medium.com/flexbox-and-grids/the-css-fractional-unit-fr-in-approachable-plain-language-fdc47bd387f7">The fractional unit (fr)</a></p><p>The fractional unit solves the problem of automatically distributing space.</p><p>If you have three grid columns aligned as shown below, the fractional unit will automatically distribute the space equally.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*1TWb0kZ4nn6uvykRLMGtOw.png" /></figure><p>If for some reason you add more elements — no worries. The fr unit will equally redistribute the space .</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*D5ILayU5dx_la2wnyn6ZYw.png" /></figure><p>Finally, if you have a fixed width element, then you can take up the remaining space with the fr unit.</p><p>Here’s what I mean:</p><pre>body {<br>   ...<br>   grid-template-rows: 1fr 100px;<br>   grid-template-columns: 50px 1fr;</pre><p>And that is it — done!</p><p>If you’re still confused with fr unit, please check out, <a href="https://medium.com/flexbox-and-grids/the-css-fractional-unit-fr-in-approachable-plain-language-fdc47bd387f7">the CSS Fractional Unit (Fr) In Approachable, plain Language</a>. It only takes 3 minutes.</p><h3>Naming and Positioning Items by Grid Areas</h3><p>We explicitly created the grid system. Now, let’s put it to use.</p><p>The goal of this section is to learn to position grid items using grid areas.</p><p>If you recall from an earlier section, a grid area is any area bounded by 4 grid lines.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7X_NTZG0ikpVwsaB0qfdAw.png" /><figcaption>The “small boxes” of grid items may be referred to as grid cells.</figcaption></figure><h4>How do you start using grid areas?</h4><p>The logical place to begin is naming grid areas.</p><p>Let me explain that.</p><p>Consider the code block below:</p><pre>&lt;div class=&quot;aside&quot;&gt;&lt;/div&gt;</pre><pre>&lt;div class=&quot;main&quot;&gt;&lt;/div&gt;</pre><pre>&lt;div class=&quot;footer&quot;&gt;&lt;/div&gt;</pre><p>3 divs — simple. By the way, It is semantically better to use aside main and footer tags. I’ll just keep things simple.</p><p>Now see this:</p><pre>.main {<br>  grid-area: content;<br>}</pre><pre>.footer {<br>  grid-area: footer;<br>}</pre><pre>.aside {<br>  grid-area: sidebar;<br>}</pre><h4>What is happening there?</h4><p>If you write a bit of Javascript, or any programming language, then the concepts of variables isn’t new to you.</p><p>In Javascript, we could say:</p><pre>var gridArea = &quot;content&quot;</pre><p>What is done above is, save the string content into the variable gridArea</p><p>What the CSS declarations above does is quite similar.</p><p>Every grid item can be assigned to an area within the grid container. Read that again.</p><blockquote>Every grid item can be assigned to an area within the grid container</blockquote><p>However, before doing that, it is imperative to attach the grid items to an area name. Like you assign variables in Javascript — sort of.</p><pre>.main {<br>  grid-area: content;<br>}</pre><pre>.footer {<br>  grid-area: footer;<br>}</pre><pre>.aside {<br>  grid-area: sidebar;<br>}</pre><p>The code block above says, let the .main class have an area name of content. Let the .footer class have an area name of footer. Finally, let the aside class have a grid name of sidebar</p><p>Now the grid items have all been assigned area names.</p><p>In programming, variables are set to be used elsewhere. Now let’s make use of the grid area names.</p><h4>Grid area placement</h4><p>A young man has a well baked cake. He has 3 children asking to give them some portions. Ideally, who shares the cake?</p><p>The young man!</p><p>The young man cuts out the areas and gives them to his children.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*xN-041OZXzMZvCJ76WRtfQ.jpeg" /><figcaption>yummy!</figcaption></figure><p>Here’s why I told that sweet story.</p><p>Like the cake, the entire grid area is owned by who?</p><p>The grid container!</p><p>Like the young man, the grid container has 3 children too .aside .main and .footer Now the grid container gets to choose how the entire area portions are shared.</p><p>One more thing.</p><p>Because the children all have names, the young man may say, <em>“hey </em><strong><em>Brian</em></strong><em>, here’s your portion”, or “hey </em><strong><em>Emma</em></strong><em>, have this”</em></p><p>It is easy to identify who owns what portion of the cake, by assigning the portions to a named individual. I have no cure for you if you live in a country where people go without names 😁</p><p>The grid items all have names! We did so using the grid-area property.</p><p>Now, let’s share the cake!</p><h4>The grid-template-areas property</h4><p>Now the grid container must share the “cake”. Assign what area portions goes to who.</p><p>There are many ways to do what I am about to explain to you, but the grid-template-areas property is the easiest to reason about. It is the bit you need to know for efficiency.</p><h4>How does the grid-template-areas property work?</h4><p>Take a look at the code below:</p><pre>body {<br>      grid-template-areas: &quot;sidebar  content&quot;<br>                           &quot;footer   footer&quot;;<br>  }</pre><p>😳 what the heck is that ?</p><p>That my dear, is the grid-template-areas property in action. There’s no need to get overwhelmed. In this section, I will explain how it works — in clear terms.</p><p>The grid-template-areas property (what a long property name) provides a very visual structure of the grid.</p><p>Take a look at the code again:</p><pre>body {<br>      ...<br>      grid-template-areas: &quot;sidebar  content&quot;<br>                           &quot;footer   footer&quot;;<br>  }</pre><p>Note that the entries in the property value are the names of the grid items!</p><p>sidebar content and footer refer to the names of the grid items. The declaration above has succesfully shared the area with respect to the names of the grid items — brilliant!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NjMwDa_1b1vHkAbpXI_f7w.png" /></figure><p>The image above will help you understand how the area portions have been split.</p><p>The footer takes the entire bottom area. The sidebar and content take first and second top areas respectively.</p><p>Awesome!</p><p>At this point here’s what we have:</p><pre>body {<br>      display: grid;<br>      grid-template-columns: 40px 1fr;<br>      grid-template-rows: 1fr 90px;<br>      grid-template-areas: &quot;sidebar  content&quot;<br>                           &quot;footer  footer&quot;;<br>  }</pre><p>The result of that is this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LNfazbNhUOy6YBEE7Sr_Uw.png" /><figcaption>STEP 1: <a href="https://codepen.io/ohansemmanuel/pen/bRWrPE">https://codepen.io/ohansemmanuel/pen/bRWrPE</a></figcaption></figure><p>I have added colors for visual aid. The red section represents the footer, the other two sections, the .main section and .sidebar.</p><h3>Let’s Get Responsive — Redefining Grid Areas with Media Queries</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*9H_Ylq3VVHRLQRTZZLYbQQ.gif" /><figcaption>gif by <a href="https://dribbble.com/msenyil">Muharrem Senyil</a></figcaption></figure><p>The Grids areas you create within the parent grid container are not set in stone. The grid areas can be changed based off of the screen size of the user’s device.</p><p>The Image below shows what we aim to achieve on mobile displays.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Gd8H2uQF3-TVi4lq7g1UAw.png" /><figcaption>Catty Music, on mobile</figcaption></figure><p>For our specific use-case we will do some refactoring for a mobile first approach.</p><p>Mobile first is simply making your default styles those for mobile devices. Then you may go ahead to make changes for larger displays via media queries.</p><p>Tweak the current code you have now. Wrap the grid defining bit in a media query.</p><p>Like this:</p><pre>@media only screen and (min-width: 600px) {<br>    body {<br>        grid-template-columns: 120px 1fr;<br>        grid-template-areas: &quot;sidebar  content&quot;<br>                             &quot;footer   footer&quot;;<br>         }<br>}</pre><p>You should leave the defaults excluded from the media query</p><pre>body {<br>    display: grid;<br>    grid-template-rows: 1fr 50px;<br>}</pre><p>Why do I have grid-template-rows: 1fr 50px excluded from the media query?</p><p>This is because both mobile and desktop screens will have the same row definition. 2 rows.</p><p>However, on desktop devices, there’s a sidebar. The sidebar accounts for the 120px in the grid-template-columns definition. Howbeit, the sidebar is non-existent on mobile devices.</p><p>Thus, we will redefine the grid-template-column declaration for mobile.</p><p>Now for mobile devices, we will leave this as the default styling. i.e not wrapped in any media query.</p><pre>body {<br>   grid-template-areas: &quot;content&quot;<br>                        &quot;footer&quot; </pre><p>Pretty simple?</p><p>Let me explain.</p><h3>The default flow (direction) of a Grid</h3><p>The code block for mobile displays is easy.</p><pre>body {<br>   grid-template-areas: &quot;content&quot;<br>                        &quot;footer&quot;</pre><p>However, note that there was no need to specify grid-template-columns</p><p>By default, a grid will align it’s children along rows.</p><p>So, the declaration above will align content along a row, and footer along another.</p><p>Below is the result of that — the sidebar hidden on mobile.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WeVXg_bAwa5UKqdZHiwQ7w.gif" /><figcaption>STEP 2: <a href="https://codepen.io/ohansemmanuel/pen/qjVvjJ?editors=1100">https://codepen.io/ohansemmanuel/pen/qjVvjJ?editors=1100</a></figcaption></figure><p>With the initial hurdle of understanding how grids work, and setting up a responsive grid, let’s finish up the app layout!</p><h3>Placing Content within the Grid.</h3><p>At the end of this section, we would have the Music app layout completed. The focus being, how to place and align content within grids.</p><p>Let’s get started.</p><h4>1. The Sidebar</h4><p>This looks like the easiest to start with. Let’s go for it.</p><p>The sidebar consists of 8 icons equally spaced out vertically accross the entire length of the sidebar.</p><p>Insert the icons, like this:</p><pre>&lt;div class=&quot;aside&quot;&gt;<br>      &lt;i class=&quot;fa fa-bars&quot;&gt;&lt;/i&gt;<br>      &lt;i class=&quot;fa fa-home&quot;&gt;&lt;/i&gt;<br>      &lt;i class=&quot;fa fa-search&quot;&gt;&lt;/i&gt;<br>      &lt;i class=&quot;fa fa-volume-up&quot;&gt;&lt;/i&gt;<br>      &lt;i class=&quot;fa fa-user&quot;&gt;&lt;/i&gt;<br>      &lt;i class=&quot;fa fa-spotify&quot;&gt;&lt;/i&gt;<br>      &lt;i class=&quot;fa fa-cog&quot;&gt;&lt;/i&gt;<br>      &lt;i class=&quot;fa fa-soundcloud&quot;&gt;&lt;/i&gt;<br>&lt;/div&gt;</pre><p>Below is the result of that:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DY1tA49VLEOy0I5Fb_HmlQ.png" /><figcaption><a href="https://codepen.io/ohansemmanuel/pen/BZmbza">https://codepen.io/ohansemmanuel/pen/BZmbza</a></figcaption></figure><p>Also, hide the icons when on mobile. Show them when the app is visited on a larger screen. This is the mobile first approach.</p><pre><br>.aside i {<br>  display: none;<br>}</pre><pre><a href="http://twitter.com/media">@media</a> only screen and (min-width:600px) {<br>  .aside i {<br>    display: block;<br>  }<br>}</pre><p>The icons are displayed, but poorly aligned.</p><h4>Aligning the icons</h4><p>The i tags are inline elements — which explains why every 2 icons sit on one line.</p><p>Let’s fix the arrangement.</p><blockquote>Grid items can be grids themselves. Why not</blockquote><h4>Step 1: Make the Sidebar a Grid Container</h4><p>This will give access to using the grid’s alignment features.</p><p>Since the sidebar is only seen on larger screens, do not forget to wrap this in the media query.</p><pre><a href="http://twitter.com/media">@media</a> only screen and (min-width:600px) {<br><br>  .aside {<br>     display: grid; <br>  }<br>  <br>  .aside i {<br>    border: 1px solid red;<br>  }<br>}</pre><p>I have gone ahead to add borders to each icon — so they are visually distinguishable.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QcpsRWdU5Q01YC-C2Et11w.png" /></figure><p>What’s happening there?</p><p>We have NOT set up any rows or columns within the sidebar. But we have the icons laid out fairly well. The grid auto placement algorithm has set in.</p><p>This is got to do with the default placement of items in a grid — along a row. Also, the grid items are arranged to take up the space of the grid container, as needed.</p><p>Here comes the sweet sauce.</p><p>A grid may align it’s items using any of justify-items or align-items.</p><p>justify-items will align the items along the row axis. In most cases, row is pretty much synonymous with the horizontal direction.</p><p>align-items will align the items along the column axis. In most cases, column is also synonymous with the vertical direction.</p><p>Apply this to the sidebar, and we have perfectly laid out icons.</p><pre>.aside {<br>     ...<br>     justify-items: center;<br>     align-items: center;<br>  }</pre><p>Still confused, watch the changes in the sidebar items as I type.</p><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fwww.youtube.com%2Fembed%2FpN2rGbEfNw8%3Ffeature%3Doembed&amp;url=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DpN2rGbEfNw8&amp;image=https%3A%2F%2Fi.ytimg.com%2Fvi%2FpN2rGbEfNw8%2Fhqdefault.jpg&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=youtube" width="854" height="480" frameborder="0" scrolling="no"><a href="https://medium.com/media/7a9c896c6f50f1f13d5d12aef9097d12/href">https://medium.com/media/7a9c896c6f50f1f13d5d12aef9097d12/href</a></iframe><p>Now we have perfectly laid out icons within the sidebar.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gwdH9pKxjMw7MnO8vPmTgw.png" /><figcaption><a href="https://codepen.io/ohansemmanuel/pen/MorYJq?editors=1100">https://codepen.io/ohansemmanuel/pen/MorYJq?editors=1100</a></figcaption></figure><p>A few other values justify-items and align-items can take include:</p><ul><li>stretch</li><li>start</li><li>end</li><li>center</li></ul><p>If you’ve worked with Flexbox, these should be familiar.</p><p>We’ll proceed to placing more content into the current design.</p><p>Target the main section, the dark blue section in the image above. Place two div within:</p><pre>&lt;div class=&quot;main&quot;&gt;<br>  &lt;div class=&quot;main__header&quot;&gt;&lt;/div&gt; <br>  &lt;div class=&quot;main__body&quot;&gt;&lt;/div&gt;<br>&lt;/div&gt;</pre><p><strong>NB:</strong></p><ol><li>main__header will house the music art and playbacks:</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K2ikIxNuiWo8tfY-5RvBXg.png" /><figcaption>.main__header</figcaption></figure><p>2. main__body will house the details:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hc80JsuD3IsxxwrAijFWzQ.png" /><figcaption>.main__body</figcaption></figure><p>In this section we will focus on main__header</p><p>First off, add the required html</p><pre>&lt;div class=&quot;main__header&quot;&gt;<br>      &lt;div class=&quot;img&quot;&gt;<br>          &lt;img src=&quot;<a href="http://bit.ly/2sc2NJd">http://bit.ly/2sc2NJd</a>&quot;/&gt;<br>      &lt;/div&gt; <br>      &lt;section class=&quot;details&quot;&gt; <br>          &lt;div&gt;<br>              &lt;p&gt;CattyBoard Top 100 Single Charts (11.06.36)&lt;/p&gt;<br>              &lt;p class=&quot;sm--hide&quot;&gt;Unknown Artist&lt;/p&gt;<br>              &lt;p class=&quot;sm--hide&quot;&gt;2016 . Charts . 100 songs&lt;/p&gt;<br>          &lt;/div&gt;<br>          &lt;div&gt; <br>               &lt;i class=&quot;fa fa-play&quot;&gt; &amp;nbsp;Play all&lt;/i&gt;<br>               &lt;i class=&quot;fa fa-plus&quot;&gt; &amp;nbsp;Add to&lt;/i&gt;<br>               &lt;i class=&quot;fa fa-ellipsis-h&quot;&gt;&amp;nbsp;&amp;nbsp;More&lt;/i&gt;<br>          &lt;/div&gt;<br>      &lt;/section&gt;<br>&lt;/div&gt;</pre><p>Note the way the document is structured.</p><p>main__header has two direct children. A div that contains an image, and a section that contains album details, .details</p><p>The result of the addition above is this rather ugly image:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uhNqMg2RUv_bo5371BrOfQ.png" /><figcaption>incomplete header</figcaption></figure><p>Let’s make this pretty.</p><p>What we need is a grid that aligns its children appropriately.</p><p>Let’s make use of your new knowledge of grid areas.</p><p>First step, define the grid areas:</p><pre>.main__header &gt; .img {<br>  grid-area: img;<br>}<br>.main__header &gt; .details {<br>  grid-area: dtls;<br>}</pre><p>The div containing the image has been named img The section containing the album details has been named dtls</p><p>Now, define the grid itself:</p><pre>.main__header {<br>  display: grid;<br>  grid-template-areas: &quot;img&quot;<br>                       &quot;dtls&quot;; <br>}</pre><p>.main__header sets a grid formatting context. The areas have also been aligned to stack vertically on another. imgfirst, then dtls</p><p>This is because we are working with a mobile first approach. Good.</p><p>At this point, nothing much’s changed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*h60PmaHUtZAMZrC5xrRtbA.png" /><figcaption>I have included borders and made the text whitish for visual aid.</figcaption></figure><p>This is NOT the view we want on mobile.</p><p>For mobile screens, the items should be aligned to the center. Fix that.</p><pre><a href="http://twitter.com/media">@media</a> screen and (max-width: 600px) {<br>  .main__header {<br>    justify-items: center;<br>  } <br>}</pre><p>Now the grid items will be positioned to the center of the grid (along the row)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/318/1*9Yi3TudvNbbTdYtDBsqL1w.png" /></figure><p>Make the texts in .detailsalign to the center:</p><pre><a href="http://twitter.com/media">@media</a> screen and (max-width: 600px) {<br>  .main__header &gt; .details {<br>    text-align: center;<br>  }  <br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/242/1*Dj_iJrYWYA4lpQdxuzx4Cw.png" /></figure><p>Pretty close to the end goal. Just a few more tweaks.</p><p>The paragraphs with the texts, <em>unknown artist, </em>and<em> 2016 . Charts. 100 songs. </em>should be hidden on mobile. The image should be smaller too.</p><pre><a href="http://twitter.com/media">@media</a> screen and (max-width: 600px) {<br>  .sm--hide {<br>    display: none;<br>  } <br>  .img &gt; img {<br>    width: 150px<br>  }<br>}</pre><p>Every class .sm--hide will be hidden on mobile. Just add this class to the desired element.</p><p>Here’s how:</p><pre>&lt;p class=&quot;sm--hide&quot;&gt;Unknown Artist&lt;/p&gt;<br>&lt;p class=&quot;sm--hide&quot;&gt;2016 . Charts . 100 songs&lt;/p&gt;</pre><p>And we have this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/295/1*3EldPliJB9kqZmu9B1UaRg.png" /></figure><p>Having sorted out the view on mobile, let’s fix that for larger screens.</p><p>Back to the parent grid.</p><p>For larger screens, we need a 2 column grid. The areas should be split like this:</p><pre><a href="http://twitter.com/media">@media</a> only screen and (min-width:600px) {<br>   .main__header {<br>    grid-template-columns: 250px 1fr;<br>    grid-template-areas: &quot;img dtls&quot;<br>  } <br>}</pre><p>I’m sure you understand what’s going on there.</p><p>The grid has been redefined to have two columns. One fixed at 250px and the other to fill the remaining space.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iFRIMSqQYAl2AhHBgsCjdw.gif" /><figcaption><a href="https://codepen.io/ohansemmanuel/pen/gReOQJ?editors=1100">https://codepen.io/ohansemmanuel/pen/gReOQJ?editors=1100</a></figcaption></figure><p>Our current progress lives <a href="https://codepen.io/ohansemmanuel/pen/gReOQJ?editors=1100">here</a>.</p><h3>Part 4: Making CSS Grid work with Flexbox</h3><p>In this part, you’ll learn to make Flexbox and Grid work together — peacefully.</p><p>These two technologies have changed how layouts in CSS are treated. It is efficient ot use both technologies where possible.</p><p>Let’s delve in.</p><p>For the section housing the music details, we will use flexbox.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hc80JsuD3IsxxwrAijFWzQ.png" /></figure><h4>How do you know where to use Flexbox?</h4><p>As a general rule of thumb, it is appropriate to use Grid to layout the overall page layout, and Flexbox for inner UI components.</p><p>A grid item can be a flex container. A flex item can also be a grid container. The latter is frequently used though.</p><p>I assume you have a good grasp of <a href="https://medium.freecodecamp.org/understanding-flexbox-everything-you-need-to-know-b4013d4dc9af">flexbox</a>.</p><p>As always, begin with the html</p><p>Below is a div, with a list of songs. The list of songs have paragraphs containing the name of the song, artiste, duration of the song and “catty cloud sync”.</p><pre>&lt;div class=&quot;main__body&quot;&gt;<br>        &lt;div&gt;<br>              &lt;p&gt;1. One Dance&lt;/p&gt;<br>              &lt;p&gt;Crake feat CatKid &amp;amp; Cyla&lt;/p&gt;<br>              &lt;p&gt;2:54&lt;/p&gt;<br>              &lt;p&gt;&lt;span&gt;CATTY CLOUD SYNC&lt;/span&gt;&lt;/p&gt;<br>        &lt;/div&gt;<br>        &lt;div&gt;<br>              &lt;p&gt;2. Panda&lt;/p&gt;<br>              &lt;p&gt;Cattee&lt;/p&gt;<br>              &lt;p&gt;4:06&lt;/p&gt;<br>              &lt;p&gt;&lt;span&gt;CATTY CLOUD SYNC&lt;/span&gt;&lt;/p&gt;<br>        &lt;/div&gt;<br>        &lt;div&gt;<br>              &lt;p&gt;3. Can&#39;t Stop the Feeling!&lt;/p&gt;<br>              &lt;p&gt;Catin Cimberlake&lt;/p&gt;<br>              &lt;p&gt;3:56&lt;/p&gt;<br>              &lt;p&gt;&lt;span&gt;CATTY CLOUD SYNC&lt;/span&gt;&lt;/p&gt;<br>         &lt;/div&gt;<br>         &lt;div&gt;<br>              &lt;p&gt;4. Work From Home&lt;/p&gt;<br>              &lt;p&gt;Cat Harmony feat Colla&lt;/p&gt;<br>              &lt;p&gt;3:34&lt;/p&gt;<br>              &lt;p&gt;&lt;span&gt;CATTY CLOUD SYNC&lt;/span&gt;&lt;/p&gt;<br>         &lt;/div&gt;<br>    &lt;/div&gt;</pre><p>Here’s what we’ve got:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lz7cE6DLCPeX-S6bwCVRJw.gif" /></figure><p>main__body is a grid item. We could make it a flex container if that was useful.</p><p>For our use case, each direct div child of main__body needs to be flex container. This is the divthat contains the name of the song, artiste, duration of the song and “catty cloud sync”.</p><pre>.main__body &gt; div {<br>  display:flex;<br>}</pre><p>Now split the width amongst the child elements:</p><pre>.main__body &gt; div p{<br>  flex: 0 0 25%;<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F7_nB62n6q9TV9aDJJ23tA.png" /><figcaption><a href="https://codepen.io/ohansemmanuel/full/pwLEBL/">https://codepen.io/ohansemmanuel/full/pwLEBL/</a></figcaption></figure><p>You’ll agree with me that at this point, the essentials of the layout is done. Yes, ✅</p><p>However, I have gone ahead to make a few cosmetic changes.</p><p>You may view the result of that <a href="https://codepen.io/ohansemmanuel/full/QgxEqz/">here</a></p><p>You’ll notice that I have left the footer blank. That’s supposed to be an exercise for you. My advice is to use flexbox. This will strengthen your understanding of getting both technologies to work together. Go ahead and make the grid item, footer a flex container.</p><p>If you need some cues, check out <a href="http://output.jsbin.com/wubudog">catty music built completely with flexbox</a>.</p><p>With just a few grid properties, you have built a real world layout. That’s pretty impressive. You’ve also learned the invaluable skill of making the CSS Grid layout work with Flexbox too.</p><h3>Want to become Pro?</h3><p>Download my free CSS Grid cheat sheet, and also get two quality interactive Flexbox courses for free!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u2ew8JU87UuAmSYWY1y8Vg.png" /><figcaption><a href="http://eepurl.com/dcNiP1">Get the Free CSS Grid Cheat sheet + Two Quality Flexbox Courses for free!</a></figcaption></figure><p><a href="http://eepurl.com/dcNiP1">Get them now</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=585d0c213577" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flexbox-and-grids/how-to-efficiently-master-the-css-grid-in-a-jiffy-585d0c213577">How to Efficiently Master the CSS Grid — in a Jiffy</a> was originally published in <a href="https://medium.com/flexbox-and-grids">Flexbox and Grid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The CSS Fractional Unit (Fr) In Approachable, plain Language.]]></title>
            <link>https://medium.com/flexbox-and-grids/the-css-fractional-unit-fr-in-approachable-plain-language-fdc47bd387f7?source=rss----c59a61117d02---4</link>
            <guid isPermaLink="false">https://medium.com/p/fdc47bd387f7</guid>
            <category><![CDATA[responsive-design]]></category>
            <category><![CDATA[flexbox]]></category>
            <category><![CDATA[css-grid]]></category>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Ohans Emmanuel]]></dc:creator>
            <pubDate>Tue, 30 May 2017 10:14:35 GMT</pubDate>
            <atom:updated>2017-12-11T17:22:19.490Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8e_NeKYW06oro3ZPKV-63Q.png" /></figure><h3>Introduction</h3><p>The fractional units(fr) is a new form of unit measurement in CSS — largely associated with the CSS Grid.</p><p>If you are not familiar with the CSS Grid, be sure to check out my <a href="https://medium.com/flexbox-and-grids/css-grid-layout-how-to-get-started-in-2-steps-well-explained-44fab69d9274">introductory article</a>.</p><h3>Story time</h3><p>Let’s pretend to forget about CSS Grid or fractional units for a bit.</p><p>Good.</p><p>So it’s holidays and you have a big, moist and fluffy cake.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xN-041OZXzMZvCJ76WRtfQ.jpeg" /><figcaption>yummy!</figcaption></figure><p>But the challenge is, you have to share the cake into 5 equal parts!</p><p>So you pick up the knife and get to work…</p><p>In 5 minutes, you have the most perfect cut. 5 equal parts!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Yo-wy0Fn-zz_3kvgjKNVg.jpeg" /><figcaption>5 equal parts…</figcaption></figure><p>Good Job!</p><p>Just when you thought you had done an amazing job, one more neighbour comes from no where and insists on having a cake too 😡 — an equal portion of cake.</p><p>Really?</p><p>What do you do?</p><p>Do you collect all the shared cakes and magically bind them together for another equal cut?</p><p><em>I ain’t doing that…</em></p><h3>Application</h3><p>This is the problem we have lived with for a long time. Like the big fluffy cake, we have a 100% width across any screen size.</p><p>Consider the markup below:</p><pre>&lt;section&gt;<br> &lt;div&gt;&lt;/div&gt;<br> &lt;div&gt;&lt;/div&gt;<br> &lt;div&gt;&lt;/div&gt;<br> &lt;div&gt;&lt;/div&gt;<br> &lt;div&gt;&lt;/div&gt;<br>&lt;/section&gt;</pre><p>We have a container section which houses 5 divs</p><p>To share the 100% width accordingly and give the divs equal widths, you’d specify an individual width of 20%</p><p>Why?</p><p>Because we have 5 divs. 100% divided by 5 gives 20%</p><p><em>“Now one more neighbour comes from no where and insists on having a cake too…”</em></p><p>If one more div is added within the section, you have to recalculate and specify the width again!</p><p>100% divided by 6 … the math is left to you😆</p><p>This is one problem the fractional unit takes away!</p><h3>The Fractional unit</h3><p>With the fractional unit(fr) you don’t need to recalculate — at all.</p><p>If you specify a width of 1fr , you can go on to add as many child elements as possible and it will be taken care of. The widths will be equally shared accross all child elements.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1TWb0kZ4nn6uvykRLMGtOw.png" /><figcaption>3 child elements</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*D5ILayU5dx_la2wnyn6ZYw.png" /><figcaption>6 child elements</figcaption></figure><p>You are NOT bound to just “ones” or “whole numbers”. You may have values like: 1.5fr 3fr 4.5fr</p><p>In this case, the <strong>total fraction is 1.5fr + 3fr + 4.5fr = 9fr</strong></p><p>If the parent container has a width of <strong>900px…</strong></p><p>The first, (1.5fr) will have a width of <strong>1.5fr/9fr * 900px</strong>. This yields <strong>150px.</strong></p><p>The second, (3fr) will have a width of<strong> 3fr/9fr * 900px</strong>. This yields <strong>300px.</strong></p><p>The third, (3fr) will have a width of<strong> 4.5fr/9fr * 900px.</strong> This yields <strong>450px</strong>.</p><p>With fractional units, a lot of flexibility is introduced. Make sure to enjoy the delight it brings to laying out contents with the CSS Grid layout.</p><h4>👉 <strong>Be sure to check out the follow up article, </strong><a href="https://medium.com/flexbox-and-grids/what-you-didnt-know-about-the-css-fractional-unit-580bd62647e8"><strong>What You Didn’t know about the CSS Fractional Unit</strong></a></h4><h3>Want to become Pro?</h3><p>Download my free CSS Grid cheat sheet, and also get two quality interactive Flexbox courses for free!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u2ew8JU87UuAmSYWY1y8Vg.png" /><figcaption><a href="http://eepurl.com/dcNiP1">Get the Free CSS Grid Cheat sheet + Two Quality Flexbox Courses for free!</a></figcaption></figure><p><a href="http://eepurl.com/dcNiP1">Get them now</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fdc47bd387f7" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flexbox-and-grids/the-css-fractional-unit-fr-in-approachable-plain-language-fdc47bd387f7">The CSS Fractional Unit (Fr) In Approachable, plain Language.</a> was originally published in <a href="https://medium.com/flexbox-and-grids">Flexbox and Grid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The CSS Grid Terminologies you Should Know]]></title>
            <link>https://medium.com/flexbox-and-grids/the-fundamental-css-grid-terminologies-fec9796acbb8?source=rss----c59a61117d02---4</link>
            <guid isPermaLink="false">https://medium.com/p/fec9796acbb8</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[grid-layout]]></category>
            <category><![CDATA[css-grid]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[web-design]]></category>
            <dc:creator><![CDATA[Ohans Emmanuel]]></dc:creator>
            <pubDate>Mon, 08 May 2017 23:29:55 GMT</pubDate>
            <atom:updated>2017-12-05T17:20:02.792Z</atom:updated>
            <content:encoded><![CDATA[<p>Here is a collection of the fundamental terminologies you need to know to use the CSS Grid layout model effectively.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L_hC4x6xvUtvs9BGNB-d1Q.png" /></figure><p>Let’s get started.</p><h3>1. What is a Grid Container?</h3><p>A Grid container is the container for which display: grid is set. In technical terms, a grid container is the container for which a grid formatting context is set.</p><p><em>Grid formatting context </em>is a fancy way to say, <em>“set up a container whose formatting is based on the rules of the Grid model”</em></p><h4>Example</h4><p>Consider the markup below:</p><pre>p {<br>  display: grid;<br>}</pre><p>The paragraph element above is a grid container. It sets a grid formatting context via display: grid</p><p>In the example above, the pelement has been set to be formatted based on the Grid model.</p><h3>2. What is a Grid Item?</h3><p>In 1 above, we looked at grid-containers.</p><p>Assume that the paragraph in 1 had a markup as follows:</p><pre>&lt;p&gt;<br>  &lt;div&gt;&lt;/div&gt;<br>  &lt;div&gt;&lt;/div&gt;<br>&lt;/p&gt;</pre><p>With p been a grid container, the div elements are automatically <em>grid items.</em></p><p>Technically, the children elements of a grid-container are called grid-items. Emphasis on <em>“children”</em></p><p>Strictly speaking, <em>grid items</em> are not restricted to only elements. e.g. the two div elements above. Anonymous bits of texts may also be grid items.</p><h4>Example</h4><p>Consider the markup below:</p><pre>&lt;p&gt;<br>  &lt;div&gt;&lt;/div&gt;<br>  I am a text<br>  &lt;div&gt;&lt;/div&gt;<br>&lt;/p&gt;</pre><p>Notice how I am a text is NOT in a separate div</p><p>In the markup above, both div items are grid-items , AND so is I am text</p><p>In conclusion, the markup has 3 grid items — the 2 div elements and the text, I am a text.</p><h3>3. What is a Grid Line?</h3><p>Assume for a bit that we have a fully laid out grid layout like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xcID2GAZoYqhb4LYjN6Qug.png" /><figcaption>supposed grid layout</figcaption></figure><p>The layout comprises a grid container with a number of perfectly laid out grid items.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*9K74dULhLERm5_3a37Byqw.png" /><figcaption>a bit of explanation</figcaption></figure><p>The grid items are represented by the little square boxes within the outer container.</p><p>Now, what’s a grid line?</p><p>A grid line is a little difficult to describe.</p><p>Take a look at the reference image above. Every straight line you see there is essentially a grid line.</p><h3>4. What is a Grid Cell?</h3><p>Again, take a look at the reference image above.</p><p>A Grid cell is the smallest unit of area in a grid layout. The small boxes of grid items may be referred to as grid cells.</p><p>More appropriately, a grid cell is any space bounded by four grid lines.</p><p>See the example grid cell below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7X_NTZG0ikpVwsaB0qfdAw.png" /><figcaption>example grid cell</figcaption></figure><h3>5. What is a Grid Area?</h3><p>A grid area is pretty easy to understand.</p><p>Remember I said the grid cell is the smallest unit of a grid area? Yes, that is right!</p><p>A grid area may be as small as the area contained within a grid cell, or as large as all the cells within the grid.</p><p>In the image below, the area covered by the four cells is also a grid area.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*_4ZnWO3zlt82VMHQ_3VNXA.png" /></figure><h3>Conclusion</h3><p>It’s easy to take fundamental concepts like the ones shared in this article for granted. But like a wise man once said, <em>“the master of the basics is the true master of the skill”.</em></p><h3>Want to become Pro?</h3><p>Download my free CSS Grid cheat sheet, and also get two quality interactive Flexbox courses for free!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u2ew8JU87UuAmSYWY1y8Vg.png" /><figcaption><a href="http://eepurl.com/dcNiP1">Get the Free CSS Grid Cheat sheet + Two Quality Flexbox Courses for free!</a></figcaption></figure><p><a href="http://eepurl.com/dcNiP1">Get them now</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fec9796acbb8" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flexbox-and-grids/the-fundamental-css-grid-terminologies-fec9796acbb8">The CSS Grid Terminologies you Should Know</a> was originally published in <a href="https://medium.com/flexbox-and-grids">Flexbox and Grid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to create horizontally scrollable sections with Flexbox]]></title>
            <link>https://medium.com/flexbox-and-grids/how-to-create-horizontally-scrollable-sections-with-flexbox-60d860f539b2?source=rss----c59a61117d02---4</link>
            <guid isPermaLink="false">https://medium.com/p/60d860f539b2</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[flexbox]]></category>
            <category><![CDATA[responsive-web-design]]></category>
            <dc:creator><![CDATA[Ohans Emmanuel]]></dc:creator>
            <pubDate>Sat, 29 Apr 2017 10:05:49 GMT</pubDate>
            <atom:updated>2017-12-05T17:20:46.049Z</atom:updated>
            <content:encoded><![CDATA[<p>This article is example focused, and the problem we’ll be solving is pretty standard.</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/1*TCzY0bGBhfqtIid6b4iBxA.gif" /><figcaption>completed scrollable section: <a href="https://codepen.io/ohansemmanuel/full/ybMwpj/">https://codepen.io/ohansemmanuel/full/ybMwpj/</a></figcaption></figure><blockquote>The road to learning by precept is long, by example short and effective — Lucius Seneca</blockquote><p>This article is example focused, and the problem we’ll be solving is pretty standard.</p><p>How do you create a section that scrolls horizontally — with great support on browsers, mobile inclusive?</p><p>Flexbox! Yeah, that’s the short answer.</p><p>Let’s flesh that out a bit.</p><h3>Basic Code Setup</h3><p>Consider the markup below.</p><p>It’s essentially a section with a couple div elements as children.</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/28e5f7642f5c972ec31b0e66e4ad882d/href">https://medium.com/media/28e5f7642f5c972ec31b0e66e4ad882d/href</a></iframe><h3>Code Styles</h3><p>Because no one loves ugly designs, let’s have some very basic styling:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/3196a2583e20591f6a0e0788c77614d3/href">https://medium.com/media/3196a2583e20591f6a0e0788c77614d3/href</a></iframe><p>The first few lines, 1 -5 explicitly sets the width and height of the root elements to 100%</p><p>Line 8 gives the body a background-color, line 9 takes away margin around the body, while lines 10 to 12 ensures that the direct child element of body is positioned exactly at the center — vertically and horizontally.</p><p>To see this in effect, give the child element, &lt;section class=”card&quot;&gt; some styling:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/ace6629deacb80e538c43c694ded4cfa/href">https://medium.com/media/ace6629deacb80e538c43c694ded4cfa/href</a></iframe><p>Line 2 is quite obvious. Line 3 ensures that the section takes 100% of it’s container’s width by default. Line 4 makes sure that the height of the section never goes below 200px</p><p>Now everything should look like this at this point:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yMys5GGgXAQebT4M7yiK6A.png" /><figcaption>Perfectly centered .card section</figcaption></figure><p>Now we will put the card--content “divs ” within the card section to good use.</p><p>Let’s have some very simple styles again.</p><p>First off, make card a flex-container:</p><pre>.card {display: flex}</pre><p>Then style .card--content as follows:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/0cd27649495bad7c0e6d2aaef8b9c499/href">https://medium.com/media/0cd27649495bad7c0e6d2aaef8b9c499/href</a></iframe><p>Line 3 ensures that the width of each card is never less than 200px , everything else is pretty simple.</p><p>Here’s the result of that:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*USLhFhboj61foWE7JvbhmQ.gif" /><figcaption>Scroll section with overflow</figcaption></figure><p>As you may have noticed, the entire page scrolls. This is because there are more elements than can be fit into the card section.</p><p>Let’s specifically tell the browser to only scroll the card section.</p><p>To do that, add this:</p><pre>.card {<br>  overflow-x: auto;<br>}</pre><p>And we have a scrollable section:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1hCmJusEIW02CtrQg8H8pQ.gif" /><figcaption>scrollable section with scrollbar</figcaption></figure><p>Good!</p><h3>Hiding the Scrollbar</h3><p>For UX reasons you may want to hide the scrollbar, and still have a scrollable section.</p><p>There’s an easy way out — for <em>webkit </em>browsers at least.</p><pre>.card::-webkit-scrollbar {<br>  display: none;<br>}</pre><p>This will hide the scrollbars, which is arguably more beautiful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TCzY0bGBhfqtIid6b4iBxA.gif" /><figcaption>complete horizontally scrolled section</figcaption></figure><h3>Applications</h3><p>I have used empty boxes to illustrate the point here. However, there could be a lot of application for this simple technique — a technique very valuable in mobile apps where you don’t have a lot of viewing space</p><p>Here are a couple examples:</p><h4>(i) You could have a bunch of Images in a horizontal section — your version of <em>instangram</em></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*MjdBUQr6HZw-PJBy9jZWUA.gif" /><figcaption><a href="https://codepen.io/ohansemmanuel/full/NjpmWY/">https://codepen.io/ohansemmanuel/full/NjpmWY/</a></figcaption></figure><h4>(ii) You could have just a bunch of texts, if that’s useful for you.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*jNdoISIdoKa4fbtacwwV7g.gif" /><figcaption><a href="https://codepen.io/ohansemmanuel/full/RVpOaV/">https://codepen.io/ohansemmanuel/full/RVpOaV/</a></figcaption></figure><p>To be honest, the possibilities are endless — all at your service.</p><h3>Want to become Pro?</h3><p>Download my free CSS Grid cheat sheet, and also get two quality interactive Flexbox courses for free!</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u2ew8JU87UuAmSYWY1y8Vg.png" /><figcaption><a href="http://eepurl.com/dcNiP1">Get the Free CSS Grid Cheat sheet + Two Quality Flexbox Courses for free!</a></figcaption></figure><p><a href="http://eepurl.com/dcNiP1">Get them now</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60d860f539b2" width="1" height="1" alt=""><hr><p><a href="https://medium.com/flexbox-and-grids/how-to-create-horizontally-scrollable-sections-with-flexbox-60d860f539b2">How to create horizontally scrollable sections with Flexbox</a> was originally published in <a href="https://medium.com/flexbox-and-grids">Flexbox and Grid</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>