<?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: Anirudh Varma</title>
    <description>The latest articles on DEV Community by Anirudh Varma (@anirudhvarma12).</description>
    <link>https://dev.to/anirudhvarma12</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F155615%2F1a9f6f39-bda3-4ce3-aacd-bfe683e0564d.jpeg</url>
      <title>DEV Community: Anirudh Varma</title>
      <link>https://dev.to/anirudhvarma12</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/anirudhvarma12"/>
    <language>en</language>
    <item>
      <title>Flexbox - Align Items vs Align Content.</title>
      <dc:creator>Anirudh Varma</dc:creator>
      <pubDate>Fri, 12 Apr 2019 11:43:09 +0000</pubDate>
      <link>https://dev.to/anirudhvarma12/flexbox-align-items-vs-align-content-3knl</link>
      <guid>https://dev.to/anirudhvarma12/flexbox-align-items-vs-align-content-3knl</guid>
      <description>&lt;p&gt;This post was originally posted on &lt;a href="https://un-defined.netlify.com/align-items-vs-content-flexbox/"&gt;my blog&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Flexbox"&gt;Flexbox&lt;/a&gt; is awesome. If you have worked with modern CSS, whether you are rolling your own or using a frameworks like Bootstrap &amp;amp; Foundation, chances are you are using Flexbox for layout and alignment.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;To align or to justify..that is the question&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;For a very long time, I have been trying to figure out what is the difference between &lt;code&gt;align-items&lt;/code&gt;, &lt;code&gt;align-content&lt;/code&gt; &amp;amp; &lt;code&gt;justify-content&lt;/code&gt; and how they work or more importantly &lt;em&gt;when&lt;/em&gt; they work.&lt;/p&gt;

&lt;h3&gt;
  
  
  TL;DR
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;If you have set your &lt;code&gt;flex-direction&lt;/code&gt; to &lt;code&gt;row&lt;/code&gt;, then &lt;code&gt;justify-content&lt;/code&gt; works on the horizontal axis and &lt;code&gt;align-*&lt;/code&gt; properties work on the vertical axis.&lt;/li&gt;
&lt;li&gt;If you have set your &lt;code&gt;flex-direction&lt;/code&gt; to &lt;code&gt;column&lt;/code&gt;, then &lt;code&gt;align-*&lt;/code&gt; properties work on the horizontal axis and &lt;code&gt;justify-content&lt;/code&gt; works on the vertical axis.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See the Pen &lt;a href="https://codepen.io/thebigfatpanda12/pen/aXqjNq/"&gt;Align items vs Justify Content&lt;/a&gt; by Anirudh Varma&lt;br&gt;
  (&lt;a href="https://codepen.io/thebigfatpanda12"&gt;@thebigfatpanda12&lt;/a&gt;) on &lt;a href="https://codepen.io"&gt;CodePen&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  What separates align-items and align-content?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;align-items&lt;/code&gt; effect the alignment of items on the current line.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;align-content&lt;/code&gt; effects the alignment accross lines of a flex-container. This means that this property has no effect on single-line containers.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;The rest of the article is just a brain dump of everything I learned while trying to figure out the above.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Nomenclature
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Flex Container&lt;/strong&gt;: An element on which the &lt;code&gt;display&lt;/code&gt; value is set to &lt;code&gt;flex&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Flex Items&lt;/strong&gt;: &lt;em&gt;Direct&lt;/em&gt; children of the flex containers are called flex items.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Main Axis&lt;/strong&gt;: The axis defined by the &lt;code&gt;flex-direction&lt;/code&gt; property.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;-- &lt;code&gt;flex-direction:row&lt;/code&gt; means that elements inside the flex container are aligned next to each other. Technically, these elements are aligned along the &lt;a href="https://www.w3.org/TR/css-writing-modes-4/#inline-axis"&gt;inline-axis&lt;/a&gt; (just like inline elements).&lt;/p&gt;

&lt;p&gt;-- &lt;code&gt;flex-direction:column&lt;/code&gt; means that elements are aligned along the vertical axis i.e. below each other. Technically called the &lt;a href="https://www.w3.org/TR/css-writing-modes-4/#block-axis"&gt;block-axis&lt;/a&gt; (just like block elements)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Cross Axis&lt;/strong&gt;: The axis perpendicular to the main axis is called the cross axis.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Single-line Container&lt;/strong&gt;: Flex containers whose &lt;code&gt;flex-wrap&lt;/code&gt; property is set to &lt;code&gt;nowrap&lt;/code&gt;. By default every flex container is a single-line container.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Multi-line Containers&lt;/strong&gt;: Flex containers whose &lt;code&gt;flex-wrap&lt;/code&gt; property is set to &lt;code&gt;wrap&lt;/code&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  TL;DR with Nomenclature
&lt;/h2&gt;

&lt;p&gt;Now that we know the jargon, we can rewrite the TL;DR as-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;justify-content&lt;/code&gt; works on the Main Axis and &lt;code&gt;align-*&lt;/code&gt; properties work on the Cross Axis.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;justify-content&lt;/code&gt; and &lt;code&gt;align-items&lt;/code&gt; are similar in their behviour, the difference being that &lt;code&gt;justify-content&lt;/code&gt; works on the the main axis while &lt;code&gt;align-items&lt;/code&gt; works on the cross axis.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;align-content&lt;/code&gt; works only on multi-line containers and has no effect on single line containers.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;a href="https://www.w3.org/TR/css-flexbox-1/"&gt;w3.org&lt;/a&gt; documentation on Flexbox is pretty comprehensive and a good read.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/CSS_layout/Flexbox"&gt;MDN&lt;/a&gt; Flexbox documentation.&lt;/li&gt;
&lt;/ol&gt;

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