English 中文(简体)
Flexbox - Flexibility
  • 时间:2024-09-17

Flexbox - Flexibipty


Previous Page Next Page  

flex-basis

We use the flex-basis property to define the default size of the flex-item before the space is distributed.

The following example demonstrates the usage of the flex-basis property. Here we are creating 3 colored boxes and fixing their size to 150 px.

<!doctype html>
<html lang = "en">
   <style>
      .box{
         font-size:15px;
         padding:15px;
      }
      .box1{background:green; flex-basis:150px; }
      .box2{background:blue; flex-basis:150px;}
      .box3{background:red; flex-basis:150px;}
      
      .container{
         display:flex;
         height:100vh;
         apgn-items:flex-start;
      }
   </style>
   
   <body>
      <span class = "container">
         <span class = "box box1">One</span>
         <span class = "box box2">two</span>
         <span class = "box box3">three</span>
      </span>
   </body>
</html>

It will produce the following result −