A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/css/properties/flex below:

flex · WebPlatform Docs

flex Summary

The flex CSS property specifies the ability of a flex item to alter its dimensions to fill the available space. flex is a shorthand property comprised of the flex-grow, flex-shrink, and flex-basis properties. A flex item can be stretched to use available space proportional to its flex grow factor, or reduced proportional to its flex shrink factor to prevent overflow.

Overview table
Initial value
0 1 auto
Applies to
flex items
Inherited
No
Media
visual
Computed value
See individual properties
Animatable
Yes
CSS Object Model Property
flex
Syntax Values
<flex-grow> <flex-shrink> <flex-basis>
The shorthand value of this property includes the following values:
3 1 60%
An example of the shorthand values.
none
Equivalent to 0 0 auto
auto
Equivalent to 1 1 auto
initial
Equivalent 0 1 auto’
Examples

The Holy Grail layout CSS: how to set up one layout that covers both desktop and mobile use cases.

body {
   font: 24px Helvetica;
   background: #999999;
  }

  #main {
   min-height: 800px;
   margin: 0px;
   padding: 0px;
   display: flex;
   flex-flow: row;
   }

  #main > article {
   margin: 4px;
   padding: 5px;
   border: 1px solid #cccc33;
   border-radius: 7pt;
   background: #dddd88;
   flex: 3 1 60%;
   order: 2;
   }

  #main > nav {
   margin: 4px;
   padding: 5px;
   border: 1px solid #8888bb;
   border-radius: 7pt;
   background: #ccccff;
   flex: 1 6 20%;
   order: 1;
   }

  #main > aside {
   margin: 4px;
   padding: 5px;
   border: 1px solid #8888bb;
   border-radius: 7pt;
   background: #ccccff;
   flex: 1 6 20%;
   order: 3;
   }

  header, footer {
   display: block;
   margin: 4px;
   padding: 5px;
   min-height: 100px;
   border: 1px solid #eebb55;
   border-radius: 7pt;
   background: #ffeebb;
   }

  
  @media all and (max-width: 640px) {

   #main, #page {
    flex-flow: column;
   }

   #main > article, #main > nav, #main > aside {
    
    order: 0;
   }

   #main > nav, #main > aside, header, footer {
    min-height: 50px;
    max-height: 50px;
   }
  }

View live example

The Holy Grail layout HTML.

<!DOCTYPE html>
<html lang="en">
  <head>
    <style>
    </style>
  </head>
  <body>
 <header>header</header>
 <div id='main'>
    <article>article</article>
    <nav>nav</nav>
    <aside>aside</aside>
 </div>
 <footer>footer</footer>
  </body>
</html>

View live example

Usage
 * Best practice is to always specify a unit for the flex-basis value, i.e. 30em or 60%.
Notes Related specifications
CSS Flexible Box Layout Module
Candidate Recommendation
See also Related articles Flexbox External resources

Also, check out the following live demo sites and article about flexbox:

Attributions

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4