InfoHeap
Tech
Navigation
  • Home
  • Tutorials
    • CSS tutorials & examples
    • CSS properties
    • Javascript cookbook
    • Linux/Unix Command Line
    • Mac
    • PHP
      • PHP functions online
      • PHP regex
    • WordPress
  • Online Tools
    • Text utilities
    • Online Lint Tools
search

CSS3 flexbox

    Flexbox container properties

    • display:flex and inline-flex
    • flex-direction
    • flex-wrap
    • flex-flow
    • justify-content
    • align-items
    • align-content

    Flexbox items properties

    • order
    • flex-grow
    • flex-shrink
    • flex-basis
    • flex
    • align-self

    Flexbox cookbooks

    • CSS flexbox - align div vertically and horizontally in center
     
    • Home
    • > Tutorials
    • > CSS
    • > CSS properties
    • > CSS3 flexbox

    CSS flex – shorthand for flex-grow, flex-shrink and flex-basis

    on Sep 10, 2016

    CSS flex is the shorthand property for flex-grow, flex-shrink and flex-basis. flex-shrink and flex-basis are optional. Its default value is 1 0 auto.

    Syntax:

    .someflexcontainer {
      display: flex;
    }
    .flexitem {
      flex: 0 1 20%;
    }

    CSS property flex

    CSS version: CSS 3
    Value: [flex-grow] [flex-shrink-optional] [flex-basis-optional]
    Initial: 1 0 auto
    Applies to: flex items
    Inherited: no

    Example – flex

    In the following code, CSS property flex can be changed to the following values
    • 0 1 20%
    • 1 1 20%
    <style>
    .fbox {
      display: flex;
      width: 250px; background-color:gray;
    }
    .child {
      background-color:green;
      padding: 3px; margin: 3px;
      /* flex-grow, flex-shrink, flex-basis */
      flex: 0 1 20%;
    }
    </style>
    
    <div class=fbox>
    <div class="child">div1</div>
    <div class="child">div2 long</div>
    <div class="child">div3</div>
    </div>
    flex refresh done
    try it online

    Specification and Browser compatibility

    SpecificationStatusCategories
    Flexible Box Layout ModuleW3C Working DraftCSS3
    Desktop
    ChromeFirefoxIEEdgeSafariOpera
    Yes 29+ Yes 28+ Partial 11+ Yes 12+ Yes 9+ Yes 12.1+
    Mobile
    Android ChromeAndroid FirefoxiOS SafariIE MobileOpera Mobile
    Yes 47+ Yes 44+ Yes 9.0-9.2+ Yes 11+ Yes 12.1+
    source: caniuse.com

    Suggested posts:

    1. CSS align-self – override align-items for flex-item
    2. CSS order – flex items ordering
    3. CSS flex-grow – grow flex item if needed
    4. CSS flex-wrap
    5. CSS flex-direction – flexbox container ordering and orientation
    6. Ruby gem – handy reference
    7. CSS flex-shrink – shrink flex item if needed
    8. CSS align-items – flexbox items vertical alignment
    Share this article: share on facebook share on linkedin tweet this submit to reddit
    Posted in Tutorials | Tagged CSS, CSS properties, CSS3 flexbox, Tutorials
    • Browse content
    • Article Topics
    • Article archives
    • Contact Us
    Popular Topics: Android Development | AngularJS | Apache | AWS and EC2 | Bash shell scripting | Chrome developer tools | Company results | CSS | CSS cookbook | CSS properties | CSS Pseudo Classes | CSS selectors | CSS3 | CSS3 flexbox | Devops | Git | HTML | HTML5 | Java | Javascript | Javascript cookbook | Javascript DOM | jQuery | Kubernetes | Linux | Linux/Unix Command Line | Mac | Mac Command Line | Mysql | Networking | Node.js | Online Tools | PHP | PHP cookbook | PHP Regex | Python | Python array | Python cookbook | SEO | Site Performance | SSH | Ubuntu Linux | Web Development | Webmaster | Wordpress | Wordpress customization | Wordpress How To | Wordpress Mysql Queries | InfoHeap Money

    Copyright © 2025 InfoHeap.

    Powered by WordPress