{"id":16539,"date":"2017-03-14T12:15:07","date_gmt":"2017-03-14T10:15:07","guid":{"rendered":"https:\/\/www.webcodegeeks.com\/?p=16539"},"modified":"2017-03-10T13:12:36","modified_gmt":"2017-03-10T11:12:36","slug":"ultimate-css3-flexbox-tutorial-2017","status":"publish","type":"post","link":"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/","title":{"rendered":"The Ultimate CSS3 Flexbox Tutorial for 2017"},"content":{"rendered":"<p>With the new CSS3 Flexbox box model, you can now write more concise and maintainable code for various common layout tasks \u2014 such as vertical centering, taking up remaining space, or simpler grids. After this tutorial, you\u2019ll be able to use Flexbox and understand exactly how it works.<\/p>\n<h2><\/h2>\n<h2>1. \u00a0Introducing Flexbox<\/h2>\n<p>The <a href=\"https:\/\/www.w3.org\/TR\/css-flexbox-1\/\" target=\"_blank\">CSS3 Flexbox spec<\/a> contains quite a few properties. It\u2019s easiest to think of them in two categories:<\/p>\n<ol>\n<li>Properties for flex containers (the parent)<\/li>\n<li>Properties for flex items (the children)<\/li>\n<\/ol>\n<p>You\u2019ll learn all of them in this tutorial. But before you do, you should always think about browser support, so let\u2019s see what <a href=\"http:\/\/caniuse.com\/#search=flexbox\" target=\"_blank\">caniuse.com<\/a> has to say:<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flexbox-browser-support.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16546\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flexbox-browser-support.png\" width=\"860\" height=\"350\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flexbox-browser-support.png 1578w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flexbox-browser-support-300x122.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flexbox-browser-support-768x312.png 768w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flexbox-browser-support-1024x417.png 1024w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>The most important info from this is:<\/p>\n<ul>\n<li><strong>97.5%<\/strong> of users worldwide support Flexbox (if you use prefixing)<\/li>\n<li>The main problems are IE11 and below, and older Android browsers<\/li>\n<\/ul>\n<p>The standard has evolved since 2009 which unfortunately brought forth three different specifications. Therefore, browser prefixes often look a bit different because they are based on different versions of the spec. Here\u2019s one example that also helps you spot outdated information on the web right away:<\/p>\n<ul>\n<li>Spec from 2009: <code>display: box<\/code><\/li>\n<li>Spec from 2011: <code>display: flexbox<\/code><\/li>\n<li>Spec from 2016: <code>display: flex<\/code><\/li>\n<\/ul>\n<p><strong>Nowadays, you make an element a Flexbox by setting <code>display: flex<\/code><\/strong> (or <code>display: inline-flex<\/code>). This allows you to use all the properties discussed in this tutorial.<\/p>\n<h2>1.1 \u00a0Main Axis &amp; Cross Axis<\/h2>\n<p>It\u2019s essential to understand the concepts of main and cross axis for everything you do with Flexbox. For row layouts, the main axis will be the horizontal axis. For column layouts, the main axis will be vertical.<\/p>\n<p>The cross axis is always perpendicular to the main axis, thus vertical for rows and horizontal for columns. Keep this in mind for what\u2019s to come.<\/p>\n<h2>2 \u00a0Styling Flex Containers<\/h2>\n<p>Let\u2019s take a look at the Flexbox properties to define the general layout of the flex container.<\/p>\n<h2>2.1 \u00a0flex-direction<\/h2>\n<p>With Flexbox, you essentially have two choices for the basic behavior of your container: either row or column layout. Additionally, each can be \u201creversed\u201d. Let\u2019s see what that means.<\/p>\n<p><code><strong>flex-direction: row<\/strong><\/code> (default)<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-direction-row.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16547\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-direction-row.png\" width=\"860\" height=\"72\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-direction-row.png 922w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-direction-row-300x25.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-direction-row-768x64.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>This is the default which behaves similar to left-floated elements in a container \u2013 but of course you\u2019ll be able to use all of the power of Flexbox on this container.<\/p>\n<p><code><strong>flex-direction: column<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-direction-column.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16548\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-direction-column.png\" width=\"860\" height=\"307\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-direction-column.png 921w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-direction-column-300x107.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-direction-column-768x274.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>In the column layout, elements will be aligned from top to bottom in a row. Each flex item will automatically take up the whole width.<\/p>\n<p><code><strong>flex-direction: row-reverse<\/strong><\/code><br \/>\n<a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-direction-row-reverse.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16549\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-direction-row-reverse.png\" width=\"860\" height=\"75\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-direction-row-reverse.png 924w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-direction-row-reverse-300x26.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-direction-row-reverse-768x67.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>This is the same as row but items are inserted from right to left (from the end of the main axis towards the front).<\/p>\n<p><code><strong>flex-direction: column-reverse<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-direction-column-reverse.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16550\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-direction-column-reverse.png\" width=\"860\" height=\"308\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-direction-column-reverse.png 921w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-direction-column-reverse-300x107.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-direction-column-reverse-768x275.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>This is the same principle as row-reverse but with the main axis now being the vertical axis.<\/p>\n<h2>2.2 \u00a0justify-content<\/h2>\n<p>With justify-content, you can define the spacing of items along the main axis. Let\u2019s look at an example for a row layout.<\/p>\n<p><code><strong>justify-content: flex-start<\/strong><\/code> (default)<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-flex-start.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16551\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-flex-start.png\" width=\"860\" height=\"89\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-flex-start.png 942w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-flex-start-300x31.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-flex-start-768x79.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>Here, the flex items align towards the start of the main axis, which in this case is the left of the row.<\/p>\n<p><code><strong>justify-content: flex-end<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-flex-end.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16552\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-flex-end.png\" width=\"860\" height=\"88\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-flex-end.png 942w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-flex-end-300x31.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-flex-end-768x78.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>In this case, items align towards the end of the main axis. For <code>flex-direction: column<\/code>, this would be the bottom.<\/p>\n<p><code><strong>justify-content: center<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-center.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16553\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-center.png\" width=\"860\" height=\"87\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-center.png 940w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-center-300x30.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-center-768x78.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>I guess this is what you expected, right? \u00a0No surprises here.<\/p>\n<p><code><strong>justify-content: space-around<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-space-around.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16554\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-space-around.png\" width=\"860\" height=\"89\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-space-around.png 941w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-space-around-300x31.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-space-around-768x79.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>This distributes spacing between the flex items evenly, also leaving whitespace at the start and end.<\/p>\n<p><code><strong>justify-content: space-between<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-space-between.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16555\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-space-between.png\" width=\"860\" height=\"87\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-space-between.png 939w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-space-between-300x30.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/justify-content-space-between-768x78.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>Works like space-around but without whitespace at the start and end of the main axis.<\/p>\n<h2>2.3 \u00a0align-items<\/h2>\n<p>With align-items, you can change the alignment of elements along the cross axis.<\/p>\n<p><code><strong>align-items: stretch<\/strong><\/code> (default)<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-stretch.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16556\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-stretch.png\" width=\"860\" height=\"137\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-stretch.png 946w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-stretch-300x48.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-stretch-768x123.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>By default, all items in the flex box will stretch to take up all space available on the cross axis.<\/p>\n<p><code><strong>align-items: flex-start<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-flex-start.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16557\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-flex-start.png\" width=\"860\" height=\"138\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-flex-start.png 941w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-flex-start-300x48.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-flex-start-768x123.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>With this, all flex items will be aligned towards the start of the cross axis. Note that\u00a0flex-start is not the default value here.<\/p>\n<p><code><strong>align-items: flex-end<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-flex-end.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16558\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-flex-end.png\" width=\"860\" height=\"136\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-flex-end.png 939w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-flex-end-300x47.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-flex-end-768x121.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>Using flex-end will accordingly align all items to the end of the cross axis.<\/p>\n<p>What would that mean in the case where you have <code>flex-direction: column<\/code>? Then this would refer to the right-hand side of the container.<\/p>\n<p><code><strong>align-items: center<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-center.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16559\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-center.png\" width=\"860\" height=\"138\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-center.png 940w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-center-300x48.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-center-768x123.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>As you would expect, this will align all items to the center of the cross axis. This is key to <a href=\"#vertical-centering\">vertical centering<\/a> of arbitrary elements!<\/p>\n<p><code><strong>align-items: baseline<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-baseline.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16560\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-baseline.png\" width=\"860\" height=\"138\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-baseline.png 944w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-baseline-300x48.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-items-baseline-768x123.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>This slightly more exotic value will align the flex items in a way that each of their content\u2019s baselines align. Thus, in the example above, the baselines of all texts align nicely.<\/p>\n<h2>2.4 \u00a0flex-wrap<\/h2>\n<p>Use flex-wrap to let the container flow into multiple rows or columns.<\/p>\n<p><code><strong>flex-wrap: nowrap<\/strong><\/code> (default)<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-wrap-nowrap.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16561\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-wrap-nowrap.png\" width=\"860\" height=\"112\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-wrap-nowrap.png 921w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-wrap-nowrap-300x39.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-wrap-nowrap-768x100.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>If you don\u2019t tell it otherwise, the flex box will not wrap its items into multiple rows or columns. This can cause the container to overflow as depicted above. In these cases, you should either reduce the content inside the flex box or use wrapping.<\/p>\n<p><code><strong>flex-wrap: wrap<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-wrap-wrap.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-16562\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-wrap-wrap.png\" alt=\"\" width=\"607\" height=\"347\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-wrap-wrap.png 607w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-wrap-wrap-300x171.png 300w\" sizes=\"(max-width: 607px) 100vw, 607px\" \/><\/a><\/p>\n<p>With this simple line, you let the flex container wrap into multiple rows or columns if it would otherwise overflow. Note that this will create a very basic grid layout \u2014 but you cannot really control what it will look like yet. Later, you\u2019ll learn how to control the sizes of each item.<\/p>\n<p><code><strong>flex-wrap: wrap-reverse<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-wrap-wrapreverse.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-16563\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-wrap-wrapreverse.png\" alt=\"\" width=\"610\" height=\"346\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-wrap-wrapreverse.png 610w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-wrap-wrapreverse-300x170.png 300w\" sizes=\"(max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>This one behaves like wrap, but rows and columns will be in reverse order \u2014 thus going from the end of the cross axis towards the start of the cross axis.<\/p>\n<h2>2.5 \u00a0align-content<\/h2>\n<p>Once you have multiple rows or columns, you can easily define their alignment and spacing using align-content. For single row\/column layouts, this will no effect.<\/p>\n<p>The possible values are exactly the same as for justify-content, but this time it will define the alignment &amp; spacing along the cross axis.<\/p>\n<p><code><strong>align-content: flex-start<\/strong><\/code> (default)<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-flex-start.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16564\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-flex-start.png\" width=\"860\" height=\"238\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-flex-start.png 938w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-flex-start-300x83.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-flex-start-768x213.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>This looks similar to align-items. However, align-items would in this case define the alignments <em>per row or column<\/em>, not the alignment of all rows\/columns inside the container.<\/p>\n<p><code><strong>align-content: flex-end<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-flex-end.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16565\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-flex-end.png\" width=\"860\" height=\"238\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-flex-end.png 939w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-flex-end-300x83.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-flex-end-768x213.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p><code><strong>align-content: center<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-center.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16566\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-center.png\" width=\"860\" height=\"240\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-center.png 939w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-center-300x84.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-center-768x214.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p><code><strong>align-content: space-around<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-space-around.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16567\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-space-around.png\" width=\"860\" height=\"239\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-space-around.png 940w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-space-around-300x83.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-space-around-768x213.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>With space-around, all rows or columns will be spaced evenly. Note the spacing before the first and after the last row in this example.<\/p>\n<p><code><strong>align-content: space-between<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-space-between.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16568\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-space-between.png\" width=\"860\" height=\"236\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-space-between.png 940w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-space-between-300x82.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-content-space-between-768x211.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>Similar to above, space-between will space all rows\/columns evenly but will not add any spacing at the very start and end.<\/p>\n<p>Those are all properties that Flexbox has to offer to define the layout <em>for flex containers<\/em>. You can see how powerful and easy to use it is \u2014 it just takes a while\u00a0to get used to all the different properties.<\/p>\n<p>For that, I very much recommend\u00a0<a href=\"http:\/\/flexboxfroggy.com\/\" target=\"_blank\">Flexbox Froggy<\/a>, a set of fun exercises to try out these new CSS properties. It will only take 5 minutes, and it\u2019s a great way to try out Flexbox.<\/p>\n<p>For levels 14 and upwards, you\u2019ll need to be able to style <em>flex items<\/em> as well. So here goes.<\/p>\n<h2>3 \u00a0Styling Flex Items<\/h2>\n<p>In addition to the basic styles for flex containers, there are many ways you can control the behavior of each flex item. Some override the general layout from the container, others define how items can grow or shrink responsively.<\/p>\n<h2>3.1 \u00a0order<\/h2>\n<p>With Flexbox, you can change the order of the flex items independent from the HTML markup. This allows more flexible layouts with less coupling to the HTML.<\/p>\n<p><code><strong>order: 0<\/strong><\/code> (default)<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/order-default.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-16569\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/order-default.png\" alt=\"\" width=\"853\" height=\"97\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/order-default.png 853w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/order-default-300x34.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/order-default-768x87.png 768w\" sizes=\"(max-width: 853px) 100vw, 853px\" \/><\/a><\/p>\n<p>By default, all flex items will have the order property set to 0. In particular, they have the same order value \u2014 therefore, their order in the layout will reflect their order in the HTML markup.<\/p>\n<p><code><strong>order: -1 and order: 1<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/order-example-1.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-16570\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/order-example-1.png\" alt=\"\" width=\"853\" height=\"97\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/order-example-1.png 853w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/order-example-1-300x34.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/order-example-1-768x87.png 768w\" sizes=\"(max-width: 853px) 100vw, 853px\" \/><\/a><\/p>\n<p>Since the default value is 0, you can use negative numbers to move an item to the front and positive numbers to move an item to the end (of the main axis).<\/p>\n<p><code><strong>order: 1, 2, 3<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/order-example-2.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-16571\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/order-example-2.png\" alt=\"\" width=\"853\" height=\"97\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/order-example-2.png 853w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/order-example-2-300x34.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/order-example-2-768x87.png 768w\" sizes=\"(max-width: 853px) 100vw, 853px\" \/><\/a><\/p>\n<p>This way, you can also easily define a completely customized order by setting the order property for each item.<\/p>\n<h2>3.2 \u00a0align-self<\/h2>\n<p>With align-self, Flexbox allows you to override the container\u2019s <a href=\"#align-items\">align-items<\/a> value. This is useful, for example, to make individual flex items stand out.<\/p>\n<p>Naturally, align-self allows the exact same values as align-items. Thus, you already know all five possible values:<\/p>\n<p><code><strong>align-self: stretch<\/strong><\/code> (default)<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-stretch.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16572\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-stretch.png\" width=\"860\" height=\"146\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-stretch.png 939w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-stretch-300x51.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-stretch-768x130.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>The item will stretch the whole cross axis, even if the container\u2019s align-items property was set to a different value.<\/p>\n<p><code><strong>align-self: flex-start<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-flex-start.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16573\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-flex-start.png\" width=\"860\" height=\"146\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-flex-start.png 939w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-flex-start-300x51.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-flex-start-768x130.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>The selected item will be aligned to the beginning of the cross axis.<\/p>\n<p><code><strong>align-self: flex-end<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-flex-end.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16574\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-flex-end.png\" width=\"860\" height=\"148\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-flex-end.png 939w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-flex-end-300x52.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-flex-end-768x132.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>The affected flex item will be aligned to the end of the cross axis.<\/p>\n<p><code><strong>align-self: center<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-center.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16575\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-center.png\" width=\"860\" height=\"146\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-center.png 940w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-center-300x51.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-center-768x131.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>The selected item will be aligned at the center of the cross axis.<\/p>\n<p><code><strong>align-self: baseline<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-baseline.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16576\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-baseline.png\" width=\"860\" height=\"146\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-baseline.png 942w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-baseline-300x51.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/align-self-baseline-768x130.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>The selected items will be aligned so that their baselines are on the same height. This once will make no difference if only one item uses baseline (this would appear like flex-start).<\/p>\n<h2>3.3 \u00a0flex-grow<\/h2>\n<p>Now we get to the more interesting, and slightly more complicated part, part of Flexbox.<\/p>\n<p>The following three properties let you define the sizing of the flex items, depending on how much space is available. For instance, you can take up any remaining space, or let the items shrink if not enough space is available.<\/p>\n<p>Firstly, flex-grow allows flex items to take up remaining space along the main axis:<\/p>\n<p><code><strong>flex-grow: 0<\/strong><\/code> (default)<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-example-1.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16577\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-example-1.png\" width=\"860\" height=\"116\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-example-1.png 874w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-example-1-300x41.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-example-1-768x104.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>Unless specified otherwise, flex items will not be allowed to grow. This is reflected by the default value of zero.<\/p>\n<p><code><strong>flex-grow: 1<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-allowed.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16578\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-allowed.png\" width=\"860\" height=\"114\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-allowed.png 872w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-allowed-300x40.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-allowed-768x102.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>You can allow items to take up remaining space along the main axis simply by setting flex-grow to 1.<\/p>\n<p><code><strong>flex-grow - Growing Evenly<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-evenly.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16579\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-evenly.png\" width=\"860\" height=\"117\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-evenly.png 871w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-evenly-300x41.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-evenly-768x105.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>Setting flex-grow to 1 for all elements in a container will cause them to take up remaining space equally. This does <em>not<\/em>\u00a0mean they will always have the same size.<\/p>\n<p>Flexbox will first consider how large the item is based on its content, padding etc \u2014 only then will it distribute the remaining space between the flex-items.<\/p>\n<p><code><strong>flex-grow - Stronger Grow<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-example-2.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16580\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-example-2.png\" width=\"860\" height=\"116\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-example-2.png 870w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-example-2-300x40.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-example-2-768x103.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>Setting a larger value for this property will make the affected item take up more space than the rest. More specifically, the third item here will get twice as much of the remaining space than the rest.<\/p>\n<p>Again, this doesn\u2019t mean the third item will be twice the size of the other items.<\/p>\n<p><code><strong>flex-grow - Another Example<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-example-3.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16581\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-example-3.png\" width=\"860\" height=\"114\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-example-3.png 872w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-example-3-300x40.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-grow-example-3-768x102.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>To exemplify this even further, consider the above example. Here, the third item will get 4\/7 of the space that remains.<\/p>\n<p><strong>Why?<\/strong> Summing up all flex-grow values amounts to 7. So you can imagine that the remaining space is split up into 7 chunks which are then distributed between the items. Items 1, 2, and 4 will get 1 chunk each, whereas item 3 will get 4 chunks \u2014 reflecting their flex-grow value.<\/p>\n<h2>3.4 \u00a0flex-shrink<\/h2>\n<p>This is the counterpart to <a href=\"#flex-grow\">flex-grow<\/a> and allows you to let items shrink of the container is overfull.<\/p>\n<p><code><strong>flex-shrink: 1<\/strong><\/code> (default)<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-shrink-default.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-16582\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-shrink-default.png\" alt=\"\" width=\"856\" height=\"117\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-shrink-default.png 856w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-shrink-default-300x41.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-shrink-default-768x105.png 768w\" sizes=\"(max-width: 856px) 100vw, 856px\" \/><\/a><\/p>\n<p>In contrast to flex-grow, flex items will shrink by default if necessary. This is reflected by the default value of 1.<\/p>\n<p><code><strong>flex-shrink: 0<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-shrink-0.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16583\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-shrink-0.png\" width=\"860\" height=\"142\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-shrink-0.png 891w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-shrink-0-300x49.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-shrink-0-768x127.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>Setting the property to zero will tell Flexbox that this item is no longer allowed to shrink, even if there\u2019s not much space.<\/p>\n<p>This can cause the container to overflow faster. But even with shrinking, the flex container can overflow, as seen under <a href=\"#flex-wrap\">flex-wrap<\/a>.<\/p>\n<p><code><strong>flex-shrink - Example<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-shrink-example.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-16584\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-shrink-example.png\" alt=\"\" width=\"857\" height=\"139\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-shrink-example.png 857w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-shrink-example-300x49.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-shrink-example-768x125.png 768w\" sizes=\"(max-width: 857px) 100vw, 857px\" \/><\/a><\/p>\n<p>Similar to flex-grow, setting a larger value for flex-shrink will allow the item to shrink more than the rest.<\/p>\n<p>However, Flexbox will always shrink items only to some degree. The more content and padding it has, the less it can be shrunk. This is important to keep in mind when items are not getting smaller even if you set <code>flex-shrink: 999<\/code>.<\/p>\n<h2>3.5 \u00a0flex-basis<\/h2>\n<p>Instead of using width and height, the best practice is to use flex-basis when dealing with a flex box. For rows, flex-basis refers to width. For columns, it refers to height. In other words, it\u2019s always the size along the main axis.<\/p>\n<p><code><strong>flex-basis: auto<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-basis-auto.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16585\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-basis-auto.png\" width=\"860\" height=\"116\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-basis-auto.png 861w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-basis-auto-300x40.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-basis-auto-768x103.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>Just like is the case for width and height, the default value for flex-basis is called auto. This way, the size of each item is defined purely by its content, padding, border, and margin.<\/p>\n<p><code><strong>flex-basis - Pixel Values<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-basis-px.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16586\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-basis-px.png\" width=\"860\" height=\"141\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-basis-px.png 865w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-basis-px-300x49.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-basis-px-768x126.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>You can use any dimensional value for flex-basis \u2014 again just like width and height. In this example, the eventual size of the items is equal to their flex-basis because enough space is available and <a href=\"#flex-grow\">flex-grow<\/a> is set to 0.<\/p>\n<p><code><strong>flex-basis - Percentage Values<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-basis-percentage.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16587\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-basis-percentage.png\" width=\"860\" height=\"117\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-basis-percentage.png 862w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-basis-percentage-300x41.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-basis-percentage-768x104.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>Similarly, you can use percentage values to define more fluid layouts, even without the help of flex-grow.<\/p>\n<h2>3.6 \u00a0flex<\/h2>\n<p>At last, there\u2019s the flex shortcut property. This one lets you define flex-grow, flex-shrink, and flex-basis in one line of code.<\/p>\n<p><code><strong>flex: 0 1 auto<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-0-1-auto.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16588\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-0-1-auto.png\" width=\"860\" height=\"116\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-0-1-auto.png 862w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-0-1-auto-300x40.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-0-1-auto-768x103.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>If you don\u2019t set a value for flex explicitly, naturally it will be set to the defaults of flex-grow, flex-shrink, and flex-basis.<\/p>\n<p><code><strong>flex: 1<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-1.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16589\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-1.png\" width=\"860\" height=\"141\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-1.png 866w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-1-300x49.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-1-768x126.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>This is a very useful shortcut for <code>flex: 1 1 0%<\/code>.<\/p>\n<p><strong>What does it do?<\/strong> It\u2019s a ridiculously easy and concise pattern to create a layout with equally sized column. This can be seen as one row of a grid. You can easily stack such rows below each other to create more complex grids, using only flex: 1.<\/p>\n<p><code><strong>flex - Example<\/strong><\/code><\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-example.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16590\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-example.png\" width=\"860\" height=\"140\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-example.png 863w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-example-300x49.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flex-example-768x125.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>This is an example showing more different values you can use for this property. Essentially, just combine what you know about flex-grow, flex-shrink, and flex-basis.<\/p>\n<h2>4. \u00a0Examples of Flexbox in Practice<\/h2>\n<p>All nice and good, but let\u2019s see how all\u00a0this will make your life as a designer easier.<\/p>\n<h2>4.1 \u00a0Simpler Grids<\/h2>\n<p>You already saw the very simplest solution for grids with Flexbox \u2014 using flex: 1. This is already all you need to create grids with columns of equal size like this:<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flexbox-grid.png\"><img decoding=\"async\" class=\"aligncenter size-full wp-image-16591\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flexbox-grid.png\" alt=\"\" width=\"842\" height=\"494\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flexbox-grid.png 842w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flexbox-grid-300x176.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/flexbox-grid-768x451.png 768w\" sizes=\"(max-width: 842px) 100vw, 842px\" \/><\/a><\/p>\n<p>For more control over the layout, you can use flex-basis to define columns of different sizes.<\/p>\n<h2>4.2 \u00a0Vertical Centering<\/h2>\n<p>Ever tried using vertical-align: middle but to no avail? I sure have. Unfortunately, it will only work for inline elements and table cells.<\/p>\n<p>With Flexbox, you can finally center arbitrary elements vertically with just one line of code \u2014 namely <code>align-items: center<\/code>.<\/p>\n<p><a href=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/vertical-centering.png\"><img decoding=\"async\" class=\"aligncenter wp-image-16592\" src=\"http:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/vertical-centering.png\" width=\"860\" height=\"191\" srcset=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/vertical-centering.png 863w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/vertical-centering-300x67.png 300w, https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2017\/03\/vertical-centering-768x171.png 768w\" sizes=\"(max-width: 860px) 100vw, 860px\" \/><\/a><\/p>\n<p>Similarly, horizontal centering can be achieved via <code>justify-content: center<\/code>.<\/p>\n<h2>4.3 \u00a0Solved by Flexbox<\/h2>\n<p>There are more common CSS tasks that have been greatly simplified by Flexbox. <a href=\"https:\/\/philipwalton.github.io\/solved-by-flexbox\/\" target=\"_blank\">Solved by Flexbox<\/a> gives a good overview of some those.<\/p>\n<p>To learn more implementing media objects, the holy grail layout, and other layouts, be sure to check out the section <a href=\"#next\">Really Dive Into Flexbox<\/a> below.<\/p>\n<h2>5. \u00a0Bonus: Flexbox Video Tutorials<\/h2>\n<p>Ready to dive into Flexbox? See it in action and code along to create your first layouts with CSS3 Flexbox.<\/p>\n<p><iframe title=\"Flexbox Tutorial #1: Why Flexbox?\" width=\"500\" height=\"281\" src=\"https:\/\/www.youtube.com\/embed\/As81w3Fiyr4?list=PLpg00ti3ApRzqcNvfyoXPbi8lNDmDHs9l\" frameborder=\"0\" allow=\"accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share\" referrerpolicy=\"strict-origin-when-cross-origin\" allowfullscreen><\/iframe><\/p>\n<h2>6. \u00a0Really Dive Into Flexbox \u2013 Where to Go From Here<\/h2>\n<p>Eager to learn all about Flexbox and reach proficiency?<\/p>\n<p>You can get my full course on Udemy for\u00a0<del>$195\u00a0<\/del>$10 \u2014 as one of my readers, you get it 95% off.<\/p>\n<p><strong><a href=\"https:\/\/www.udemy.com\/flexbox-tutorial?couponCode=AMAZINGREADERS10\">&gt;&gt; Check out the full curriculum<\/a><\/strong><\/p>\n<p><strong>Reviews From My Students<\/strong><\/p>\n<p><em>Great course! Great instructor. Explains everything very clearly and easy to understand.<\/em><br \/>\n\u2013 Bryan<\/p>\n<p><em>To the point and informative.<\/em><br \/>\n\u2013 Michael<\/p>\n<p><em>Very good course\u2026content is clear and well structured..explanation easy to understand.<\/em><br \/>\n\u2013 Martin<\/p>\n<p><em>Dude sounds super nice and he\u2019s been really thorough from the beginning. I look forward to taking the rest of the course!<\/em><br \/>\n\u2013 Aaron<\/p>\n<p><em>Good, thorough explanations of concepts with a well-spoken, easy to follow format. The mini challenges were a good bonus too!<\/em><br \/>\n\u2013 Ben<\/p>\n<p><strong><a href=\"https:\/\/www.udemy.com\/flexbox-tutorial?couponCode=AMAZINGREADERS10\">&gt;&gt; Get the complete Flexbox course for $10<\/a><\/strong><\/p>\n<p>Of course, I\u2019ll answer all your questions about Flexbox along the way. Also, you\u2019ll get a 30-day money back guarantee on Udemy. I\u2019d be super happy to welcome you inside the course!<\/p>\n<h2>7. \u00a0Get The Flexbox Cheat Sheet<\/h2>\n<p>As a token of appreciation for making it this far, you can download my <a href=\"http:\/\/petersommerhoff.com\/wp-content\/uploads\/2017\/03\/flexbox-cheat-sheet.pdf\">Flexbox Cheat Sheet<\/a>. It contains all the Flexbox properties that are explained in this post in one PDF overview.<\/p>\n<p>Please post your questions, suggestions, thoughts in the comments, I appreciate it!<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td><span class=\"reference\">Reference: <\/span><\/td>\n<td><a href=\"http:\/\/petersommerhoff.com\/web\/flexbox\/\">The Ultimate CSS3 Flexbox Tutorial for 2017<\/a> from our <a href=\"http:\/\/www.webcodegeeks.com\/join-us\/wcg\/\">WCG partner<\/a> Peter Sommerhoff at the <a href=\"http:\/\/petersommerhoff.com\/\">PeterSommerhoff<\/a> blog.<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>With the new CSS3 Flexbox box model, you can now write more concise and maintainable code for various common layout tasks \u2014 such as vertical centering, taking up remaining space, or simpler grids. After this tutorial, you\u2019ll be able to use Flexbox and understand exactly how it works. 1. \u00a0Introducing Flexbox The CSS3 Flexbox spec &hellip;<\/p>\n","protected":false},"author":226,"featured_media":917,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[11],"tags":[453],"class_list":["post-16539","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-css","tag-flexbox"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>The Ultimate CSS3 Flexbox Tutorial for 2017 - Web Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"With the new CSS3 Flexbox box model, you can now write more concise and maintainable code for various common layout tasks \u2014 such as vertical centering,\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The Ultimate CSS3 Flexbox Tutorial for 2017 - Web Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"With the new CSS3 Flexbox box model, you can now write more concise and maintainable code for various common layout tasks \u2014 such as vertical centering,\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/\" \/>\n<meta property=\"og:site_name\" content=\"Web Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/webcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2017-03-14T10:15:07+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Peter Sommerhoff\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@webcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Peter Sommerhoff\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"13 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/\"},\"author\":{\"name\":\"Peter Sommerhoff\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/e39f098f8c0dd385879a582ba4744e1b\"},\"headline\":\"The Ultimate CSS3 Flexbox Tutorial for 2017\",\"datePublished\":\"2017-03-14T10:15:07+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/\"},\"wordCount\":2477,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg\",\"keywords\":[\"Flexbox\"],\"articleSection\":[\"CSS\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/\",\"name\":\"The Ultimate CSS3 Flexbox Tutorial for 2017 - Web Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg\",\"datePublished\":\"2017-03-14T10:15:07+00:00\",\"description\":\"With the new CSS3 Flexbox box model, you can now write more concise and maintainable code for various common layout tasks \u2014 such as vertical centering,\",\"breadcrumb\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/#primaryimage\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.webcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"CSS\",\"item\":\"https:\/\/www.webcodegeeks.com\/category\/css\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"The Ultimate CSS3 Flexbox Tutorial for 2017\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#website\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"name\":\"Web Code Geeks\",\"description\":\"Web Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.webcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.webcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/webcodegeeks\",\"https:\/\/x.com\/webcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/e39f098f8c0dd385879a582ba4744e1b\",\"name\":\"Peter Sommerhoff\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/aadcfb3d351c8fa1fc217deb257c36dd8cebb1fc1bd7882081d467076700bf10?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/aadcfb3d351c8fa1fc217deb257c36dd8cebb1fc1bd7882081d467076700bf10?s=96&d=mm&r=g\",\"caption\":\"Peter Sommerhoff\"},\"description\":\"Peter is a software developer from Germany with a passion for software design. He teaches programming, web development and other techy stuff on Udemy and blogs over at PeterSommerhoff.com\",\"sameAs\":[\"http:\/\/petersommerhoff.com\/\"],\"url\":\"https:\/\/www.webcodegeeks.com\/author\/peter-sommerhoff\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"The Ultimate CSS3 Flexbox Tutorial for 2017 - Web Code Geeks - 2026","description":"With the new CSS3 Flexbox box model, you can now write more concise and maintainable code for various common layout tasks \u2014 such as vertical centering,","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/","og_locale":"en_US","og_type":"article","og_title":"The Ultimate CSS3 Flexbox Tutorial for 2017 - Web Code Geeks - 2026","og_description":"With the new CSS3 Flexbox box model, you can now write more concise and maintainable code for various common layout tasks \u2014 such as vertical centering,","og_url":"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/","og_site_name":"Web Code Geeks","article_publisher":"https:\/\/www.facebook.com\/webcodegeeks","article_published_time":"2017-03-14T10:15:07+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg","type":"image\/jpeg"}],"author":"Peter Sommerhoff","twitter_card":"summary_large_image","twitter_creator":"@webcodegeeks","twitter_site":"@webcodegeeks","twitter_misc":{"Written by":"Peter Sommerhoff","Est. reading time":"13 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/#article","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/"},"author":{"name":"Peter Sommerhoff","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/e39f098f8c0dd385879a582ba4744e1b"},"headline":"The Ultimate CSS3 Flexbox Tutorial for 2017","datePublished":"2017-03-14T10:15:07+00:00","mainEntityOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/"},"wordCount":2477,"commentCount":0,"publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg","keywords":["Flexbox"],"articleSection":["CSS"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/","url":"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/","name":"The Ultimate CSS3 Flexbox Tutorial for 2017 - Web Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.webcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/#primaryimage"},"image":{"@id":"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/#primaryimage"},"thumbnailUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg","datePublished":"2017-03-14T10:15:07+00:00","description":"With the new CSS3 Flexbox box model, you can now write more concise and maintainable code for various common layout tasks \u2014 such as vertical centering,","breadcrumb":{"@id":"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/#primaryimage","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2014\/10\/css3-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.webcodegeeks.com\/css\/ultimate-css3-flexbox-tutorial-2017\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.webcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"CSS","item":"https:\/\/www.webcodegeeks.com\/category\/css\/"},{"@type":"ListItem","position":3,"name":"The Ultimate CSS3 Flexbox Tutorial for 2017"}]},{"@type":"WebSite","@id":"https:\/\/www.webcodegeeks.com\/#website","url":"https:\/\/www.webcodegeeks.com\/","name":"Web Code Geeks","description":"Web Developers Resource Center","publisher":{"@id":"https:\/\/www.webcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.webcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.webcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.webcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.webcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/webcodegeeks","https:\/\/x.com\/webcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/e39f098f8c0dd385879a582ba4744e1b","name":"Peter Sommerhoff","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.webcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/aadcfb3d351c8fa1fc217deb257c36dd8cebb1fc1bd7882081d467076700bf10?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/aadcfb3d351c8fa1fc217deb257c36dd8cebb1fc1bd7882081d467076700bf10?s=96&d=mm&r=g","caption":"Peter Sommerhoff"},"description":"Peter is a software developer from Germany with a passion for software design. He teaches programming, web development and other techy stuff on Udemy and blogs over at PeterSommerhoff.com","sameAs":["http:\/\/petersommerhoff.com\/"],"url":"https:\/\/www.webcodegeeks.com\/author\/peter-sommerhoff\/"}]}},"_links":{"self":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/16539","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/users\/226"}],"replies":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/comments?post=16539"}],"version-history":[{"count":0,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/posts\/16539\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media\/917"}],"wp:attachment":[{"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/media?parent=16539"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/categories?post=16539"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.webcodegeeks.com\/wp-json\/wp\/v2\/tags?post=16539"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}