Set the initial length of a flex item with CSS

Set the length of a flex item with the flex-basis CSS property.


You can try to run the following code to implement the flex-basis property −

Live Demo

<!DOCTYPE html>
         .mycontainer {
            display: flex;
            background-color: orange;
         .mycontainer > div {
            background-color: white;
            text-align: center;
            line-height: 40px;
            font-size: 25px;
            width: 100px;
            margin: 5px;
      <div class = "mycontainer">
         <div style = "flex-basis: 350px">Q4</div>
Samual Sam
Samual Sam

Learning faster. Every day.