<?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: Timothy Koech</title>
    <description>The latest articles on DEV Community by Timothy Koech (@timosville).</description>
    <link>https://dev.to/timosville</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%2F34398%2F07e26ad7-3345-4d22-a1a4-22623402ea5a.jpeg</url>
      <title>DEV Community: Timothy Koech</title>
      <link>https://dev.to/timosville</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/timosville"/>
    <language>en</language>
    <item>
      <title>Sticky Footer using Tailwind CSS</title>
      <dc:creator>Timothy Koech</dc:creator>
      <pubDate>Thu, 03 Oct 2019 16:19:18 +0000</pubDate>
      <link>https://dev.to/timosville/sticky-footer-using-tailwind-css-225p</link>
      <guid>https://dev.to/timosville/sticky-footer-using-tailwind-css-225p</guid>
      <description>&lt;p&gt;I started experimenting with Tailwind CSS a couple of months ago and I'm loving it. The idea is to finally use Tailwind CSS on my website.&lt;/p&gt;

&lt;p&gt;Normally, I like to have my HTML page layout semantically divided into these sections; &lt;code&gt;header&lt;/code&gt;, &lt;code&gt;main&lt;/code&gt; and &lt;code&gt;footer&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;header&amp;gt;&lt;/span&gt;
    Navigation bar
  &lt;span class="nt"&gt;&amp;lt;/header&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;main&amp;gt;&lt;/span&gt;
    Page content
  &lt;span class="nt"&gt;&amp;lt;/main&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;footer&amp;gt;&lt;/span&gt;
    Social links
  &lt;span class="nt"&gt;&amp;lt;/footer&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To keep the &lt;code&gt;footer&lt;/code&gt; section at the bottom of the browser window, we need to add flexbox utility classes provided by Tailwind CSS like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;body&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"flex flex-col min-h-screen "&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;header&amp;gt;&lt;/span&gt;
    Navigation bar
  &lt;span class="nt"&gt;&amp;lt;/header&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;main&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"flex-grow"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Page content
  &lt;span class="nt"&gt;&amp;lt;/main&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;footer&amp;gt;&lt;/span&gt;
    Social links
  &lt;span class="nt"&gt;&amp;lt;/footer&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  The utility classes
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;.flex&lt;/code&gt;&lt;br&gt;
This sets the &lt;code&gt;body&lt;/code&gt; element into a flex container. All direct children of the &lt;code&gt;body&lt;/code&gt; element will become flex-items.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;.flex-col&lt;/code&gt;&lt;br&gt;
This defines the direction of the flex-items; &lt;code&gt;header&lt;/code&gt;, &lt;code&gt;main&lt;/code&gt; and &lt;code&gt;footer&lt;/code&gt;.&lt;br&gt;
We want the layout of the page to resemble a &lt;em&gt;column&lt;/em&gt; where the flex-items are arranged from top to bottom.&lt;br&gt;
By default, flexbox arranges flex-items horizontally in a &lt;em&gt;row&lt;/em&gt; from left to right.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;.min-h-screen&lt;/code&gt;&lt;br&gt;
This class ensures the layout takes up the full height of the browser window.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;code&gt;.flex-grow&lt;/code&gt;&lt;br&gt;
Adding this class to &lt;code&gt;main&lt;/code&gt; makes it grow, occupying all the available space on the screen. The available space is equal to the size of the flex container, &lt;code&gt;body&lt;/code&gt;, minus the sum of the flex-items &lt;code&gt;header&lt;/code&gt; and &lt;code&gt;footer&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/timosville/embed/MWWgJGY?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;To stick the footer at the bottom using plain CSS and flexbox.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;min-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100vh&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;flex-direction&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;column&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;main&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c"&gt;/* Or flex-grow: 1;*/&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/"&gt;A Complete Guide to Flexbox&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://tailwindcss.com/docs/flex-direction"&gt;Tailwind CSS Documentation&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/flex-grow"&gt;Flex-grow - MDN Documentation&lt;/a&gt;&lt;/p&gt;

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