flex-basis

  • Revision slug: Web/CSS/flex-basis
  • Revision title: flex-basis
  • Revision id: 494161
  • Created:
  • Creator: kscarfone
  • Is current revision? No
  • Comment Updated tags

Revision Content

{{ CSSRef("CSS Flexible Boxes") }}

Summary

The CSS flex-basis property specifies the flex basis which is the initial main size of a flex item.

{{cssbox("flex-basis")}}

See Using CSS flexible boxes for more properties and information.

Syntax

Formal syntax: {{csssyntax("flex-basis")}}
flex-basis: value

flex-basis: inherit

Values

percentage
Computed value returns a percentage of the parent flex container main size property. Negative values are invalid.
absolute length
Defined as a number followed by a absolute unit such as px, mm or pt. Negative values are invalid.
initial
Refers to the default value of the property.
auto
The computed value of flex-basis equals the computed value of the main size of the flex item.
Note: Writing Modes Level 3 specification will introduce the following new keywords: min-content, max-content, fill-available and fit-content.
Note: flex-basis determines the size of the content-box unless specified otherwise using {{ Cssxref("box-sizing") }}.

Examples

element { 
  flex-basis: 18em;
}

Specifications

Specification Status Comment
{{ SpecName('CSS3 Flexbox', '#flex-basis', 'flex-basis') }} {{ Spec2('CSS3 Flexbox') }}  

Browser compatibility

{{ CompatibilityTable() }}

Feature Firefox (Gecko) Chrome Internet Explorer Opera Safari
Basic support {{ CompatGeckoDesktop("18.0") }} (behind a pref) [1]
{{ CompatGeckoDesktop("22.0") }}
21.0{{ property_prefix("-webkit") }} {{ CompatNo() }} 12.10 {{ CompatNo() }}
Feature Firefox Mobile (Gecko) Android IE Phone Opera Mobile Safari Mobile
Basic support {{ CompatUnknown() }} {{ CompatUnknown() }} {{ CompatNo() }} 12.10 {{ CompatNo() }}

[1] Firefox supports only single-line flexbox. To activate flexbox support, for Firefox 18 and 19, the user has to change the about:config preference "layout.css.flexbox.enabled" to true.

See also

Revision Source

<p>{{ CSSRef("CSS Flexible Boxes") }}</p>
<h2 id="Summary">Summary</h2>
<p>The <a href="/en-US/docs/CSS" title="CSS">CSS</a> <code>flex-basis</code> property specifies the flex basis which is the initial <strong>main size</strong> of a flex item.</p>
<p>{{cssbox("flex-basis")}}</p>
<p>See&nbsp;<a href="/en/CSS/Using_CSS_flexible_boxes" title="/en/CSS/Using_CSS_flexible_boxes">Using CSS flexible boxes</a>&nbsp;for more properties and information.</p>
<h2 id="Syntax">Syntax</h2>
<pre class="twopartsyntaxbox">
<a href="/en-US/docs/CSS/Value_definition_syntax" title="/en-US/docs/CSS/Value_definition_syntax">Formal syntax</a>: {{csssyntax("flex-basis")}}
</pre>
<pre>
flex-basis: <em>value</em>

flex-basis: inherit
</pre>
<h3 id="Values">Values</h3>
<dl>
 <dt>
  <code>percentage</code></dt>
 <dd>
  Computed value returns a percentage of the parent flex container main size property. Negative values are invalid.</dd>
 <dt>
  <code>absolute length</code></dt>
 <dd>
  Defined as a number followed by a absolute unit such as <code>px</code>, <code>mm</code> or <code>pt</code>. Negative values are invalid.</dd>
 <dt>
  <code>initial</code></dt>
 <dd>
  Refers to the default value of the property.</dd>
 <dt>
  <code>auto</code></dt>
 <dd>
  The computed value of <code>flex-basis</code> equals the computed value of the main size of the flex item.</dd>
</dl>
<div class="note">
 <strong>Note:</strong> Writing Modes Level 3 specification will introduce the following new keywords: <code>min-content</code>, <code>max-content</code>, <code>fill-available</code> and <code>fit-content</code>.</div>
<div class="note">
 <strong>Note:</strong> <code>flex-basis</code> determines the size of the content-box unless specified otherwise using {{ Cssxref("box-sizing") }}.</div>
<h2 id="Examples">Examples</h2>
<pre class="brush:css;highlight:[2]">
element { 
  flex-basis: 18em;
}
</pre>
<h2 id="Specifications">Specifications</h2>
<table class="standard-table">
 <thead>
  <tr>
   <th>Specification</th>
   <th>Status</th>
   <th>Comment</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{ SpecName('CSS3 Flexbox', '#flex-basis', 'flex-basis') }}</td>
   <td>{{ Spec2('CSS3 Flexbox') }}</td>
   <td>&nbsp;</td>
  </tr>
 </tbody>
</table>
<h2 id="Browser_compatibility">Browser compatibility</h2>
<p>{{ CompatibilityTable() }}</p>
<div id="compat-desktop">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Firefox (Gecko)</th>
    <th>Chrome</th>
    <th>Internet Explorer</th>
    <th>Opera</th>
    <th>Safari</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>{{ CompatGeckoDesktop("18.0") }} (behind a pref) [1]<br />
     {{ CompatGeckoDesktop("22.0") }}</td>
    <td>21.0{{ property_prefix("-webkit") }}</td>
    <td>{{ CompatNo() }}</td>
    <td>12.10</td>
    <td>{{ CompatNo() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<div id="compat-mobile">
 <table class="compat-table">
  <tbody>
   <tr>
    <th>Feature</th>
    <th>Firefox Mobile (Gecko)</th>
    <th>Android</th>
    <th>IE&nbsp;Phone</th>
    <th>Opera Mobile</th>
    <th>Safari Mobile</th>
   </tr>
   <tr>
    <td>Basic support</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatUnknown() }}</td>
    <td>{{ CompatNo() }}</td>
    <td>12.10</td>
    <td>{{ CompatNo() }}</td>
   </tr>
  </tbody>
 </table>
</div>
<p>[1] Firefox supports only single-line flexbox. To activate flexbox support, for Firefox 18 and 19, the user has to change the about:config preference "layout.css.flexbox.enabled" to <code>true</code>.</p>
<h2 id="See_also">See also</h2>
<ul>
 <li><a href="/en-US/docs/CSS/Using_CSS_flexible_boxes" title="/en-US/docs/CSS/Using_CSS_flexible_boxes">Using CSS flexible boxes</a></li>
 <li>{{ CSS_Reference:FlexBox() }}</li>
</ul>
Revert to this revision