| Start | |||||||||
|---|---|---|---|---|---|---|---|---|---|
Dynamic Vertical and Horizontal Centering (align-items, justify-content) Simple Example (centering a single element)HTMLCSSHere is a demo (opens new window). Reasoning
Individual Property ExamplesAll of the below styles are applied onto this simple layout: where Example: |
|||||||||
| Sticky Variable-Height Footer This code creates a sticky footer. When the content doesn't reach the end of the viewport, the footer sticks to the bottom of the viewport. When the content extends past the bottom of the viewport, the footer is also pushed out of the viewport. View Result (opens new window) HTML: CSS: |
|||||||||
| Optimally fit elements to their container One of the nicest features of flexbox is to allow optimally fitting containers to their parent element. HTML: CSS: Outcome: Columns adapt as screen is resized. |
|||||||||
| Holy Grail Layout using Flexbox Holy Grail layout (opens new window) is a layout with a fixed height header and footer, and a center with 3 columns. The 3 columns include a fixed width sidenav, a fluid center, and a column for other content like ads (the fluid center appears first in the markup). CSS Flexbox can be used to achieve this with a very simple markup: HTML Markup: CSS: |
|||||||||
| Perfectly aligned buttons inside cards with flexbox It's a regular pattern in design these days to vertically align call to actions inside its containing cards like this: This can be achieved using a special trick with HTML First of all, we use CSS to apply CSS The layout will change and become like this: In order to move the buttons to the bottom of the block, we need to apply Final CSS: |
|||||||||
| Same height on nested containers This code makes sure that all nested containers are always the same height. This is done by assuring that all nested elements are the same height as the containing parrent div. See working example (opens new window): https://jsfiddle.net/3wwh7ewp/ (opens new window) This effect is achieved due to the property HTML CSS Note: Does not work on IE versions under 10 (opens new window) Syntax
RemarksVender Prefixes
Resources |
Read Article
https://develop.horje.com/learn/1434/reference