Giter VIP home page Giter VIP logo

css-flexbox's Introduction

css flexbox

  1. Example on using flexbox.
  2. Parent level apis for display:flex
Display Flex parent level properties
  1. flex-flow this contains flex-direction & flex-wrap.

Example:

flex-flow: row wrap;

flex-direction: functions by ** Main Axis vs. Cross Axis ** concept

# flex-direction: row
main axis starts on the Left--->
                            |
                            |
                            cross axis
# flex-direction: row-reverse
<-----| Main axis starts from Right
      |
      |
      cross axis
# flex-direction: column
|---->Cross axis Left--->Right
|                          
|                            
Main Axis heads TOP--->BOTTOM
# flex-direction: column-reverse
Main Axis heads BOTTOM--->UP
|
|                          
|---->Cross axis Left--->Right       

  1. align-items: adjusted by cross axis So if flex-direction: row & alight-items: center, then the content would be centered coming from the top ---> bottom.

  1. justify-content: adjusted by main-axis So if flex-direction: row & justify-content: center, then the content would be centered coming from the left ---> center.

  1. align-content: defines extra space characteristics based on cross-axis. All these <div> will have there blank spaces adjusted. So align-content:space-between would adjust the space (on view resizing) to keep the <div> sizes by forcing them to the ends so a large amount of white space would appear between them.

Display Flex items **single "div"

*** All these child properties are affected by flex-flow!

  1. order property Ex. order:1 on the first div would position it last. All other divs are treated as order:0 by default.

  1. align-self property - based on parent cross-axis Ex. flex-direction: row in parent and set align-self:flex-start on the child div would set it at the top of the page.

  1. flex - contains 3 properties (flex-grow, flex-shrink, flex-basis)
# flex default setting
# 0 = flex-grow
# 1 = flex-shrink
# auto = flex-basis

flex: 0 1 auto;

flex-grow

  • default adjustments are all flex-grow:0
  • flex-grow will grow will increase the width to fill the whole page
  • And if a div is set to flex-grow:1 and another div is set to flex-grow:2 They will both grow but at a 2:1 ratio

flex-shrink

  • default adjustments are all flex-shrink:1
  • Just like flex-grow, giving another div a setting of flex-shrink:2 will cause it to shrink 2xmore

flex-basis

  • default adjustments are all flex-basis:auto
  • Always the size of the element relating to the Main Axis. So a height setting (effected by flex-direction: column) and width (effected by flex-direction:row)
  • *** heights and width in parent or sibiling divs will affect a div set with flex-basis:???px

css-flexbox's People

Stargazers

Nick Anderson avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.