|
| 1 | +--- |
| 2 | +title: "Flexible web layout" |
| 3 | +tags: [layout, web, angular] |
| 4 | +category: "layout" |
| 5 | +comment: true |
| 6 | +--- |
| 7 | + |
| 8 | +## Background |
| 9 | + |
| 10 | +When we read the content from browser, it would render the content based on [CSS basic box model][css-box]. |
| 11 | + |
| 12 | +However, it needs many items and attributes to control the view, so it is complicated to setup and easy to get messed. |
| 13 | + |
| 14 | +The problems from classic web layouts made web designers just using tricky and weird workaround to avoid. |
| 15 | + |
| 16 | +As a result, W3C suggested using new web layout, [flex][flex-layout], to design HTML frontend, that provide an easier all-around solution. |
| 17 | + |
| 18 | +Until now, flex layout has already became a major web layout used for modern web designers and framework. |
| 19 | + |
| 20 | +The new layout is lesser properties to know and also smarter which many attributes are calculated by render engine. |
| 21 | + |
| 22 | +The following is showing all the CSS attributes having in flex web layout, it's obviously a right layout solution. |
| 23 | + |
| 24 | +## Properties |
| 25 | + |
| 26 | +There are the properties contained in flex layout in YAML format. |
| 27 | + |
| 28 | +```yaml |
| 29 | +--- |
| 30 | +flex-container: |
| 31 | + axis: |
| 32 | + - main start/end(-) |
| 33 | + - cross start/end(|) |
| 34 | + attributes: |
| 35 | + flex-direction: [row, row-reverse, column, column-reverse] |
| 36 | + flex-wrap: [nowrap, wrap, wrap-reverse] |
| 37 | + flex-flow: "${flex-direction} ${flex-wrap}" |
| 38 | + justify-content: [flex-start, flex-end, center, space-between, space-around] |
| 39 | + align-items: [flex-start, flex-end, center, baseline, stretch] |
| 40 | + align-content: [stretch, flex-start, flex-end, center, space-between, space-around] |
| 41 | + flex-item: |
| 42 | + axis: |
| 43 | + - main size(-) |
| 44 | + - cross size(|) |
| 45 | + attributes: |
| 46 | + order: "<integer>" |
| 47 | + flex-grow: "<number>" |
| 48 | + flex-shrink: "<number>" |
| 49 | + flex-basis: "auto | <length>" |
| 50 | + flex: "${flex-grow} ${flex-shrink} ${flex-basis} | auto | none" |
| 51 | + align-self: [auto, flex-start, flex-end, center, baseline, stretch] |
| 52 | +--- |
| 53 | +``` |
| 54 | + |
| 55 | +[flex-layout]: https://css-tricks.com/snippets/css/a-guide-to-flexbox/ |
| 56 | +[css-box]: https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Box_Model/Introduction_to_the_CSS_box_model |
0 commit comments