Repository: philipwalton/solved-by-flexbox Branch: master Commit: 01af9bc0c2c8 Files: 51 Total size: 73.6 KB Directory structure: gitextract_6lnvp84o/ ├── .eslintrc ├── .gitignore ├── .jshintrc ├── LICENSE ├── README.md ├── assets/ │ ├── css/ │ │ ├── base/ │ │ │ ├── custom-media.css │ │ │ ├── elements.css │ │ │ └── variables.css │ │ ├── components/ │ │ │ ├── aligner.css │ │ │ ├── browser.css │ │ │ ├── button.css │ │ │ ├── container.css │ │ │ ├── demo.css │ │ │ ├── error.css │ │ │ ├── feature.css │ │ │ ├── footer.css │ │ │ ├── grid.css │ │ │ ├── header.css │ │ │ ├── holy-grail.css │ │ │ ├── image.css │ │ │ ├── input-add-on.css │ │ │ ├── media.css │ │ │ ├── notice.css │ │ │ ├── section.css │ │ │ └── site.css │ │ ├── main.css │ │ ├── utils/ │ │ │ ├── compat.css │ │ │ ├── media.css │ │ │ └── size.css │ │ └── vendor/ │ │ ├── font-awesome-extensions.css │ │ ├── highlight.css │ │ └── twitter.css │ └── main.js ├── config.json ├── demos/ │ ├── grids.md │ ├── holy-grail.md │ ├── input-add-ons.md │ ├── media-object.md │ ├── sticky-footer.md │ └── vertical-centering.md ├── gulpfile.js ├── index.html ├── package.json ├── rollup.config.js └── templates/ ├── default.html ├── footer.html ├── head.html ├── header.html ├── holy-grail.html ├── home.html └── scripts.html ================================================ FILE CONTENTS ================================================ ================================================ FILE: .eslintrc ================================================ { "parser": "babel-eslint", "env": { "browser": true, "es6": true, "node": true, "mocha": true }, "globals": { "browser": false }, "extends": [ "eslint:recommended" ] } ================================================ FILE: .gitignore ================================================ # OS or Editor folders .DS_Store # npm/yarn files node_modules *.log *.lock # Static site output _tmp/ solved-by-flexbox/ ================================================ FILE: .jshintrc ================================================ { "browser": true, "boss": true, "esnext": true, "expr": true, "node": true, "quotmark": "single" } ================================================ FILE: LICENSE ================================================ Copyright (c) 2015 Philip Walton Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ================================================ FILE: README.md ================================================ # Solved by Flexbox A showcase of problems once hard or impossible to solve with CSS alone, now made trivially easy with Flexbox. [View Site](https://philipwalton.github.io/solved-by-flexbox/) ## Viewing the Site Locally The Solved by Flexbox site can be built with [Node.js](http://nodejs.org/). If you have Node.js installed on your system, you can run the following commands to build and serve a local copy. ```sh # Clone the git repository and cd into the cloned directory. git clone https://github.com/philipwalton/solved-by-flexbox.git cd solved-by-flexbox # Install the dependencies npm install # Build and serve the site at http://localhost:4000 npm start ``` This starts up a local server on port 4000. To view the site in your browser, navigate to [http://localhost:4000](http://localhost:4000). If you want to use a different port, you can pass the port number as an argument to `npm start`: ```sh npm start -- -p 8080 ``` In addition to building the site and serving it locally, this will also listen for any changes and rebuild the site as needed. This allows you to play around with the code, refresh the browser, and see your changes instantly. ## Translations The following translations have been graciously provided by the community: * [Chinese](https://hufan-akari.github.io/solved-by-flexbox/) * [Japanese](http://hashrock.github.io/solved-by-flexbox-ja/) * [Korean](https://hyunseob.github.io/solved-by-flexbox-kr/) Please note that translations are unofficial and may be inaccurate or out of date. To submit your own translation, please submit a [pull request](https://github.com/philipwalton/solved-by-flexbox/pull/new/master) or [open an issue](https://github.com/philipwalton/solved-by-flexbox/issues/new) and link to your translated content. ================================================ FILE: assets/css/base/custom-media.css ================================================ @custom-media --break-sm (min-width: 384px); @custom-media --break-md (min-width: 576px); @custom-media --break-lg (min-width: 768px); @custom-media --high-dppx (-webkit-min-device-pixel-ratio: 1.5), (min-resolution: 144dpi), (min-resolution: 1.5dppx); ================================================ FILE: assets/css/base/elements.css ================================================ *, *::after, *::before { box-sizing: border-box; } html { height: 100%; color: hsl(0,0%,25%); font: 400 1em/1.4 'Open Sans', sans-serif; text-rendering: optimizeLegibility; } @media (--high-dppx) { html { font-weight: 300; } } h1 { font-weight: 300; font-size: 2em; -webkit-font-kerning: normal; letter-spacing: -.015em; line-height: 1; margin: .25em 0 .75em; } @media (--break-lg) { h1 { font-size: 2.5em; margin: .5em 0 1em; } } h2 { font-size: 1.333em; font-weight: 600; margin: 0 0 calc(1.5em/1.333); } h3 { font-size: 1em; font-weight: 600; margin: 0 0 1.5em; } p, pre { margin: 0 0 1.5em; } code, pre { font-family: 'Menlo', 'Monaco', monospace; } code { font-size: .9em; font-weight: normal; color: #000; } pre > code { font: inherit; color: inherit; } a { border-bottom: 1px dashed hsla(150, 45%, 50%, 0.5); color: hsl(150, 45%, 50%); text-decoration: none; } a:focus, a:hover { border-bottom: 1px solid hsl(150, 45%, 50%); } ol, ul { list-style: square; margin: 0 0 1.5em; padding: 0 0 0 1.5em; } li { margin-bottom: 0.333em; } figure { margin: 0; } strong { font-weight: 600; } ================================================ FILE: assets/css/base/variables.css ================================================ :root { --space: 1.5em; --space-lg: 2em; --bg-color: hsl(150, 45%, 50%); } ================================================ FILE: assets/css/components/aligner.css ================================================ .Aligner { display: flex; align-items: center; min-height: 24em; justify-content: center; } .Aligner-item { flex: 1; } .Aligner-item--top { align-self: flex-start; } .Aligner-item--bottom { align-self: flex-end; } .Aligner-item--fixed { flex: none; max-width: 50%; } ================================================ FILE: assets/css/components/browser.css ================================================ .Browser { font-size: .8em; text-align: center; } .Browser-image { height: 64px; width: 64px; margin: 0 0.5em 0.5em; background: url('images/browser-logos.jpg') no-repeat 0 0; background-size: auto 100%; } .Browser--chrome > .Browser-image { background-position: 0 0; } .Browser--opera > .Browser-image { background-position: -64px 0; } .Browser--firefox > .Browser-image { background-position: -128px 0; } .Browser--safari > .Browser-image { background-position: -192px 0; } .Browser--ie > .Browser-image { background-position: -256px 0; } .Browser--edge > .Browser-image { background-position: -320px 0; } ================================================ FILE: assets/css/components/button.css ================================================ .Button { transition: background-color 0.2s; display: inline-block; padding: 0.6em 1em; background: hsla(31, 15%, 50%, 0.15); color: inherit; border: 0; border-radius: 2px; cursor: pointer; font-size: 0.8125em; font-weight: 300; line-height: normal; text-decoration: none; white-space: nowrap; } .Button:focus { outline: thin dotted #666; text-decoration: none; } .Button:active, .Button:focus, .Button:hover { border: 0; background: hsla(31, 15%, 50%, 0.25); text-decoration: none; } .Button--action { background-color: hsl(150, 45%, 50%); color: #fff; } .Button--action:active, .Button--action:focus, .Button--action:hover { background-color: hsl(150, 45%, 40%); } .Button--wide { padding-right: 1.5em; padding-left: 1.5em; } ================================================ FILE: assets/css/components/container.css ================================================ .Container { max-width: 50em; margin: 0 auto; } ================================================ FILE: assets/css/components/demo.css ================================================ .Demo { width: 100%; padding: .8em 1em 0; background: hsla(31, 15%, 50%, 0.1); border-radius: 3px; } .Demo::after { content: '\00a0'; /* */ display: block; margin-top: 1em; height: 0px; visibility: hidden; } .Demo--spaced { margin-bottom: var(--space); } ================================================ FILE: assets/css/components/error.css ================================================ .Error { padding: 1em 1.5em; background: #c00; color: #fff; font-weight: 700; text-align: center; } ================================================ FILE: assets/css/components/feature.css ================================================ .Feature { } .Feature-figure { margin-bottom: 0.75em; border: 1px solid hsl(0, 0%, 85%); transition: border-color 0.2s; } .Feature-image { display: block; max-width: 100%; height: auto; border: 5px solid hsl(0, 100%, 100%); } .Feature-title { margin: 0 0 0.5em; color: hsl(0, 0%, 25%); text-align: center; transition: color 0.1s; } .Feature-description { margin: 0 0.75em; font-size: 0.8em; } .Feature a:active .Feature-figure, .Feature a:focus .Feature-figure, .Feature a:hover .Feature-figure { border-color: hsl(150, 45%, 50%); } .Feature a:active .Feature-title, .Feature a:focus .Feature-title, .Feature a:hover .Feature-title { color: hsl(150, 45%, 50%); } ================================================ FILE: assets/css/components/footer.css ================================================ .Footer { padding: 1.5rem 1.5rem; background: hsl(0, 0%, 25%); color: hsl(0, 0%, 60%); font-size: 0.85em; overflow-x: hidden; text-align: center; } .Footer a { padding-bottom: 1px; border: 0; color: hsl(0, 0%, 90%); } .Footer a:focus, .Footer a:active, .Footer a:hover { color: #fff; text-decoration: underline; } .Footer-credits { margin: 0; padding: 0; } .Footer-credit { display: block; margin: 0; } .Footer-creditSeparator { display: none; } /* The GitHub button updates the link to be a span */ .Footer-social > span { margin-right: 1em; } /* If loading the social button fails */ .Footer-social a, .Footer-social iframe { display: inline-block; margin: 0 0 1em; vertical-align: top; } @media (--break-md) { .Footer-credit { display: inline-block; margin: 0 0.25em; } .Footer-creditSeparator { display: inline-block; padding: 0 0.25em; } } ================================================ FILE: assets/css/components/grid.css ================================================ .Grid { display: flex; flex-wrap: wrap; list-style: none; margin: 0; padding: 0; } .Grid-cell { flex: 1; } .Grid--flexCells > .Grid-cell { display: flex; } .Grid--top { align-items: flex-start; } .Grid--bottom { align-items: flex-end; } .Grid--center { align-items: center; } .Grid--justifyCenter { justify-content: center; } .Grid-cell--top { align-self: flex-start; } .Grid-cell--bottom { align-self: flex-end; } .Grid-cell--center { align-self: center; } .Grid-cell--autoSize { flex: none; } .Grid--fit > .Grid-cell { flex: 1; } .Grid--full > .Grid-cell { flex: 0 0 100%; } .Grid--1of2 > .Grid-cell { flex: 0 0 50%; } .Grid--1of3 > .Grid-cell { flex: 0 0 33.3333%; } .Grid--1of4 > .Grid-cell { flex: 0 0 25%; } @media (--break-sm) { .small-Grid--fit > .Grid-cell { flex: 1; } .small-Grid--full > .Grid-cell { flex: 0 0 100%; } .small-Grid--1of2 > .Grid-cell { flex: 0 0 50%; } .small-Grid--1of3 > .Grid-cell { flex: 0 0 33.3333%; } .small-Grid--1of4 > .Grid-cell { flex: 0 0 25%; } } @media (--break-md) { .med-Grid--fit > .Grid-cell { flex: 1; } .med-Grid--full > .Grid-cell { flex: 0 0 100%; } .med-Grid--1of2 > .Grid-cell { flex: 0 0 50%; } .med-Grid--1of3 > .Grid-cell { flex: 0 0 33.3333%; } .med-Grid--1of4 > .Grid-cell { flex: 0 0 25%; } } @media (--break-lg) { .large-Grid--fit > .Grid-cell { flex: 1; } .large-Grid--full > .Grid-cell { flex: 0 0 100%; } .large-Grid--1of2 > .Grid-cell { flex: 0 0 50%; } .large-Grid--1of3 > .Grid-cell { flex: 0 0 33.3333%; } .large-Grid--1of4 > .Grid-cell { flex: 0 0 25%; } } .Grid--gutters { margin: -1em 0 1em -1em; } .Grid--gutters > .Grid-cell { padding: 1em 0 0 1em; } .Grid--guttersLg { margin: -1.5em 0 1.5em -1.5em; } .Grid--guttersLg > .Grid-cell { padding: 1.5em 0 0 1.5em; } .Grid--guttersXl { margin: -2em 0 2em -2em; } .Grid--guttersXl > .Grid-cell { padding: 2em 0 0 2em; } @media (--break-sm) { .small-Grid--gutters { margin: -1em 0 1em -1em; } .small-Grid--gutters > .Grid-cell { padding: 1em 0 0 1em; } .small-Grid--guttersLg { margin: -1.5em 0 1.5em -1.5em; } .small-Grid--guttersLg > .Grid-cell { padding: 1.5em 0 0 1.5em; } .small-Grid--guttersXl { margin: -2em 0 2em -2em; } .small-Grid--guttersXl > .Grid-cell { padding: 2em 0 0 2em; } } @media (--break-md) { .med-Grid--gutters { margin: -1em 0 1em -1em; } .med-Grid--gutters > .Grid-cell { padding: 1em 0 0 1em; } .med-Grid--guttersLg { margin: -1.5em 0 1.5em -1.5em; } .med-Grid--guttersLg > .Grid-cell { padding: 1.5em 0 0 1.5em; } .med-Grid--guttersXl { margin: -2em 0 2em -2em; } .med-Grid--guttersXl > .Grid-cell { padding: 2em 0 0 2em; } } @media (--break-lg) { .large-Grid--gutters { margin: -1em 0 1em -1em; } .large-Grid--gutters > .Grid-cell { padding: 1em 0 0 1em; } .large-Grid--guttersLg { margin: -1.5em 0 1.5em -1.5em; } .large-Grid--guttersLg > .Grid-cell { padding: 1.5em 0 0 1.5em; } .large-Grid--guttersXl { margin: -2em 0 2em -2em; } .large-Grid--guttersXl > .Grid-cell { padding: 2em 0 0 2em; } } ================================================ FILE: assets/css/components/header.css ================================================ .Header { padding: 1.5em; background-color: rgba(147, 128, 108, 0.1); text-align: center; } @media (--break-lg) { .Header { padding: 3em 1.5em; } } .Header-title { margin: 0 0 0.15em; font-size: 1.8em; font-weight: 600; line-height: 1; word-spacing: 0.08em; } .Header-title i { font-family: serif; font-style: italic; font-weight: 400; } .Header-title a { border: 0; color: inherit; font-weight: inherit; } .Header-title a:focus, .Header-title a:hover, .Header-title a:active { text-decoration: none; } @media (--break-lg) { .Header-title { font-size: 4em; } } .Header-subTitle { margin: 0 0 1.5em; font-size: 0.8em; font-weight: 300; white-space: nowrap; } @media (--break-lg) { .Header-subTitle { margin: 1em 0 1.75em; font-size: 1.1em; } } .Header-actions { display: flex; align-items: stretch; flex-direction: column; font-size: 0.9em; } @media (--break-sm) { .Header-actions { align-items: center; flex-direction: row; justify-content: center; } } @media (--break-lg) { .Header-actions { font-size: 1.1em; } } .Header-button:first-child { margin: 0 0 1em; } @media (--break-sm) { .Header-button:first-child { margin: 0 1em 0 0; } } @media (--break-lg) { .Header--cozy { display: flex; padding: 1.5em; align-items: center; } .Header--cozy .Header-titles { display: flex; align-items: baseline; } .Header--cozy .Header-title { font-size: 1.5em; } .Header--cozy .Header-subTitle { margin: 0 0 0 1em; font-size: 0.8em; font-weight: 300; color: gray; } .Header--cozy .Header-actions { flex: 1; justify-content: flex-end; font-size: 0.9em; } } ================================================ FILE: assets/css/components/holy-grail.css ================================================ /** * 1. Avoid the IE 10-11 `min-height` bug. * 2. Set `flex-shrink` to `0` to prevent some browsers from * letting these items shrink to smaller than their content's default * minimum size. See http://bit.ly/1Mn35US for details. * 3. Use `%` instead of `vh` since `vh` is buggy in older mobile Safari. */ .HolyGrail { display: flex; height: 100%; /* 1, 3 */ flex-direction: column; } .HolyGrail-header, .HolyGrail-footer { flex: none; /* 2 */ } .HolyGrail-body { display: flex; flex: 1 0 auto; /* 2 */ flex-direction: column; padding: var(--space); } .HolyGrail-content { margin-top: var(--space); } .HolyGrail-nav { order: -1; } .HolyGrail-nav, .HolyGrail-ads { padding: 1em; border-radius: 3px; background: rgba(147, 128, 108, 0.1); } @media (--break-lg) { .HolyGrail-body { flex-direction: row; } .HolyGrail-content { flex: 1; padding: 0 var(--space-lg); margin: 0; } .HolyGrail-nav, .HolyGrail-ads { flex: 0 0 12em; } } ================================================ FILE: assets/css/components/image.css ================================================ .Image { display: block; width: 40px; height: auto; margin-top: 0.2em; } .Image--tiny { width: 30px; } @media (--break-md) { .Image { width: 70px; } .Image--tiny { width: 40px; } } ================================================ FILE: assets/css/components/input-add-on.css ================================================ .InputAddOn { display: flex; margin-bottom: 1.5em; } .InputAddOn-field { flex: 1; } .InputAddOn-field:not(:first-child) { border-left: 0; } .InputAddOn-field:not(:last-child) { border-right: 0; } .InputAddOn-item { background-color: rgba(147, 128, 108, 0.1); color: #666666; font: inherit; font-weight: normal; } .InputAddOn-field, .InputAddOn-item { border: 1px solid rgba(147, 128, 108, 0.25); padding: 0.5em 0.75em; } .InputAddOn-field:first-child, .InputAddOn-item:first-child { border-radius: 2px 0 0 2px; } .InputAddOn-field:last-child, .InputAddOn-item:last-child { border-radius: 0 2px 2px 0; } ================================================ FILE: assets/css/components/media.css ================================================ .Media { display: flex; align-items: flex-start; margin-bottom: 1em; } .Media-figure { margin-right: 1em; } .Media-body { flex: 1; } .Media-body, .Media-body :last-child { margin-bottom: 0; } .Media-title { margin: 0 0 .5em; } .Media--center { align-items: center; } .Media--reverse > .Media-figure { order: 1; margin: 0 0 0 1em; } ================================================ FILE: assets/css/components/notice.css ================================================ .Notice { background-color: hsl(90, 100%, 93%); color: hsla(0, 0%, 0%, .6); font-size: .9em; margin-bottom: var(--space); padding: 1.2em 1.5em; } ================================================ FILE: assets/css/components/section.css ================================================ .Section { padding: 0 var(--space); } .Section:nth-child(2n) { background-color: hsla(31, 15%, 50%, 0.1); overflow: hidden; /* Contain margins. */ } .Section::before, .Section::after { content: '\00a0'; /* */ display: block; height: 0px; visibility: hidden; } .Section::before { margin-bottom: var(--space); } .Section::after { margin-top: var(--space); } @media (--break-lg) { .Section { padding: 0 var(--space-lg); } .Section::before { margin-bottom: var(--space-lg); } .Section::after { margin-top: var(--space-lg); } } .Section-heading { text-align: center; } @media (--break-lg) { .Section-list { padding: 0; margin: 0 calc(2 * var(--space-lg)) var(--space-lg); } } ================================================ FILE: assets/css/components/site.css ================================================ /** * 1. Avoid the IE 10-11 `min-height` bug. * 2. Set `flex-shrink` to `0` to prevent some browsers from * letting these items shrink to smaller than their content's default * minimum size. See http://bit.ly/1Mn35US for details. * 3. Use `%` instead of `vh` since `vh` is buggy in older mobile Safari. */ .Site { display: flex; flex-direction: column; height: 100%; /* 1, 3 */ } .Site-header, .Site-footer { flex: none; /* 2 */ } .Site-content { flex: 1 0 auto; /* 2 */ padding: var(--space) var(--space) 0; width: 100%; } .Site-content::after { content: '\00a0'; /* */ display: block; margin-top: var(--space); height: 0px; visibility: hidden; } @media (--break-lg) { .Site-content { padding-top: var(--space-lg); } .Site-content::after { margin-top: var(--space-lg); } } .Site-content--full { padding: 0; } .Site-content--full::after { content: none; } ================================================ FILE: assets/css/main.css ================================================ @import 'normalize.css'; @import 'suitcss-utils-display'; @import 'suitcss-utils-text'; @import './base/variables'; @import './base/custom-media'; @import './base/elements'; @import './components/aligner'; @import './components/browser'; @import './components/button'; @import './components/container'; @import './components/demo'; @import './components/error'; @import './components/feature'; @import './components/footer'; @import './components/grid'; @import './components/header'; @import './components/holy-grail'; @import './components/image'; @import './components/input-add-on'; @import './components/media'; @import './components/notice'; @import './components/section'; @import './components/site'; @import './utils/compat'; @import './utils/media'; @import './utils/size'; @import './vendor/font-awesome-extensions'; @import './vendor/highlight'; @import './vendor/twitter'; ================================================ FILE: assets/css/utils/compat.css ================================================ /** * Fixes the min-height bug in IE10-11. * This class should be added to a container element as described in * Flexbug #3. See http://bit.ly/1gy8OJS for details. */ .u-ieMinHeightBugFix { display: flex; flex-direction: column; } ================================================ FILE: assets/css/utils/media.css ================================================ @import '../base/custom-media'; .u-full { width: 100% !important; flex: none !important; } .u-1of2 { width: 50% !important; flex: none !important; } .u-1of3 { width: 33.3333% !important; flex: none !important; } .u-2of3 { width: 66.6667% !important; flex: none !important; } .u-1of4 { width: 25% !important; flex: none !important; } .u-3of4 { width: 75% !important; flex: none !important; } @media (--break-sm) { .u-small-full { width: 100% !important; flex: none !important; } .u-small-1of2 { width: 50% !important; flex: none !important; } .u-small-1of3 { width: 33.3333% !important; flex: none !important; } .u-small-2of3 { width: 66.6667% !important; flex: none !important; } .u-small-1of4 { width: 25% !important; flex: none !important; } .u-small-3of4 { width: 75% !important; flex: none !important; } } @media (--break-md) { .u-med-full { width: 100% !important; flex: none !important; } .u-med-1of2 { width: 50% !important; flex: none !important; } .u-med-1of3 { width: 33.3333% !important; flex: none !important; } .u-med-2of3 { width: 66.6667% !important; flex: none !important; } .u-med-1of4 { width: 25% !important; flex: none !important; } .u-med-3of4 { width: 75% !important; flex: none !important; } } @media (--break-lg) { .u-large-full { width: 100% !important; flex: none !important; } .u-large-1of2 { width: 50% !important; flex: none !important; } .u-large-1of3 { width: 33.3333% !important; flex: none !important; } .u-large-2of3 { width: 66.6667% !important; flex: none !important; } .u-large-1of4 { width: 25% !important; flex: none !important; } .u-large-3of4 { width: 75% !important; flex: none !important; } } ================================================ FILE: assets/css/utils/size.css ================================================ .u-smaller { font-size: 0.85em; } .u-bigger { font-size: 1.2em; } ================================================ FILE: assets/css/vendor/font-awesome-extensions.css ================================================ .icon-big { font-size: 1.5em; } ================================================ FILE: assets/css/vendor/highlight.css ================================================ @import "highlight.js/styles/github"; pre { border-radius: 3px; background: hsla(31, 15%, 50%, 0.1); font-size: 0.85em; margin-bottom: calc(var(--space)/0.85); overflow-x: auto; padding: 1.25em 1.5em; } ================================================ FILE: assets/css/vendor/twitter.css ================================================ .twitter-follow-button { width: 235px !important; } .twitter-color { color: #00ACED; } ================================================ FILE: assets/main.js ================================================ import {getCLS, getFCP, getFID, getLCP} from 'web-vitals'; const thresholds = { CLS: [0.1, 0.25], FCP: [1800, 3000], FID: [100, 300], LCP: [2500, 4000], } function getRating(value, thresholds) { if (value > thresholds[1]) { return 'poor'; } if (value > thresholds[0]) { return 'ni'; } return 'good'; } function sendToGoogleAnalytics({name, value, delta, id}) { gtag('event', name, { value: Math.round(name === 'CLS' ? delta * 1000 : delta), event_category: 'Web Vitals', event_label: getRating(value, thresholds[name]), event_id: id, non_interaction: true, }); } getCLS(sendToGoogleAnalytics); getFCP(sendToGoogleAnalytics); getFID(sendToGoogleAnalytics); getLCP(sendToGoogleAnalytics); ================================================ FILE: config.json ================================================ { "title": "Solved by Flexbox", "tagline": "Cleaner, hack-free CSS", "description": "A showcase of problems once hard or impossible to solve with CSS alone, now made trivially easy with Flexbox." } ================================================ FILE: demos/grids.md ================================================ --- template: default.html title: Better, Simpler Grid Systems excerpt: Flexbox gives us most of the features we want from a grid system out of the box. And sizing and alignment are just one or two properties away. --- Most grid systems today use one of two layout methods: `float` or `inline-block`. But neither of these methods were really intended to be used for layout and as a result have pretty significant problems and limitations. Using floats requires clearing them which has a whole host of layout issues, most notoriously that clearing an element sometimes forces it below an unrelated part of the page (take this [Bootstrap issue](https://github.com/twbs/bootstrap/issues/295#issuecomment-2282969) for example). In addition, clearing floats usually requires using both before and after pseudo-elements, preventing you from using them for something else. Inline block layouts must address the problem of [white-space between inline-block items](http://css-tricks.com/fighting-the-space-between-inline-block-elements/), and all of the [solutions](http://davidwalsh.name/remove-whitespace-inline-block) to that problem are [hacky](https://github.com/suitcss/components-grid/blob/master/lib/grid.css#L30) and [annoying](https://twitter.com/thierrykoblentz/status/305152267374428160). Flexbox not only eliminates these problems, it opens up an entirely new world of possibilities. ## Features of a Flexbox Grid System Grid systems usually come with a myriad of sizing options, but the vast majority of the time you just want two or three elements side-by-side. Given this, why should we be required to put sizing classes on every single cell? Listed below are some of my criteria for an ideal grid system. Fortunately, with Flexbox we get most of these features for free. - By default, each grid cell is the same width and height as every other cell in the row. Basically they all size to fit by default. - For finer control, you can add sizing classes to individual cells. Without these classes, the cells simply divide up the available space as usual. - For responsive grids, you can add media query-specific classes to the cells. - Individual cells can be aligned vertically to the top, bottom, or middle. - When you want all of the cells in a grid to have the same sizing, media, or alignment values, you should be able to just add a single class to the container to avoid unnecessary repetition. - Grids can be nested as many levels deep as needed. ### Basic Grids The grid cells below do not specify any widths, they just naturally space themselves equally and expand to fit the entire row. They're also equal height by default.
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur ac nisl quis massa vulputate adipiscing. Vivamus sit amet risus ligula. Nunc eu pulvinar augue.
Donec imperdiet sem leo, id rutrum risus aliquam vitae. Cras tincidunt porta mauris, vel feugiat mauris accumsan eget.
Phasellus vel felis purus. Aliquam consequat pellentesque dui, non mollis erat dictum sit amet. Curabitur non quam dictum, consectetur arcu in, vehicula justo. Donec tortor massa, eleifend nec viverra in, aliquet at eros. Mauris laoreet condimentum mauris, non tempor massa fermentum ut. Integer gravida pharetra cursus. Nunc in suscipit nunc.
Donec imperdiet sem leo, id rutrum risus aliquam vitae. Vestibulum ac turpis non lacus dignissim dignissim eu sed dui.
Nunc nec fermentum dolor. Duis at iaculis turpis. Sed rutrum elit ac egestas dapibus. Duis nec consequat enim.
Phasellus vel felis purus. Aliquam consequat pellentesque dui, non mollis erat dictum sit amet. Curabitur non quam dictum, consectetur arcu in, vehicula justo.
Mauris porta arcu id magna adipiscing lacinia at congue lacus. Vivamus blandit quam quis tincidunt egestas. Etiam posuere lectus sed sapien malesuada molestie.
Vestibulum ac turpis non lacus dignissim dignissim eu sed dui. Proin a ligula sit amet massa malesuada mattis eu a ante. Nunc porttitor sed quam quis sollicitudin. Vestibulum ac turpis non lacus dignissim dignissim eu sed dui.
Rutrum risus aliquam vitae.
Phasellus vel felis purus. Aliquam consequat pellentesque dui, non mollis erat dictum sit amet. Curabitur non quam dictum, consectetur arcu in, vehicula justo. Donec tortor massa, eleifend nec viverra in, aliquet at eros. Mauris laoreet condimentum mauris, non tempor massa fermentum ut.
Donec imperdiet sem leo, id rutrum risus aliquam vitae.
Mauris porta arcu id magna adipiscing lacinia at congue lacus. Vivamus blandit quam quis tincidunt egestas. Etiam posuere lectus sed sapien malesuada molestie. Aliquam vitae pharetra dolor. Nullam non mattis nunc.
…
This box is both vertically and horizontally centered. Even if the text in this box changes to make it wider or taller, the box will still be centered. Go ahead, give it a try. Just click to edit the text.
CSS has been lacking proper layout mechanisms for far too long. Transitions, animations, filters, all of these are great and useful additions to the language, but they don't address the major problems that Web developers have been complaining about for what seems like an eternity.
Finally, thanks to Flexbox, we have a solution.
This site is not another CSS framework. Instead, its purpose is to showcase problems once hard or impossible to solve with CSS alone, now made trivially easy with Flexbox. With the release of Internet Explorer 11 and Safari 6.1, the latest Flexbox spec is now supported in every modern browser.
Check out the demos below. View the styles in the Web inspector or dive into the source to see just how easy CSS layout becomes with Flexbox.
{{ demo.excerpt }}
display:flexbox).All of the code samples on this site show how to solve a particular design problem with Flexbox. They show just the code that's needed to make the demos work in a spec-compliant browser. Some browsers do not fully comply with the latest version of the spec, so sadly, a few workarounds were necessary.
Workarounds for non-compliant browsers are not shown in the code samples, but if you're curious about those implementation details, you can check out the source files. Each demo links to its source, and all browser-specific workarounds are well-documented, so don't be afraid to take a look.
The vendor prefixing and translating of current flex properties to their legacy equivalents is all handled by autoprefixer. If you're writing Flexbox code and not using autoprefixer, well, you're making a horrible mistake.
The class naming convention used in the code samples and source files is taken from SUIT CSS, which is based on BEM methodologies. Each example includes one or more reusable CSS components allowing you to adapt or copy these patterns in to your own projects. Links are provided to their respective components on each example page.
If you find a mistake or would like to suggest an additional example, feel free to open an issue or submit a pull request on Github.
The following translations have been graciously provided by the community:
Please note that translations are unofficial and may be inaccurate or out of date. To submit your own translation, please submit a pull request or open an issue on GitHub and link to your translated content.