flexbox - prevent increasing the width when specifying flex-grow value

I’m trying to use flexbox to build a responsive grid of equally sized cells. My code works if the contents of the cells is the same, but does not if the contents of the cells varies in length - the cells re-adjust to accommodate their content.

Here’s what I’m after:
1. every cell is the same width
2. each cell’s width auto-adjusts when the browser is resized.

Here’s my code on fiddle: https://jsfiddle.net/v0erefnd/1/

html:

<div class="flex-container">
1
100
10,000
1,000,000
100,000,000
10,000,000,000
1,000,000,000,000
</div>
<div class="flex-container">
100
100
100
100
100
100
100
</div>

css:

.flex-container {   padding: 0;   margin: 0;   list-style: none;   display: -webkit-box;   display: -moz-box;   display: -ms-flexbox;   display: -webkit-flex;   display: flex;   -webkit-flex-flow: row;   justify-content: space-around;   height: 50px;   line-height:30px;
}


.flex-item {   /*todo: how to prevent the flexbox to resize to accommodate the text?*/   background: tomato;   margin: 10px 5px;   color: white;   font-weight: bold;   font-size: 1.5em;   text-align: center;   flex-grow: 1;   overflow: hidden;
}

Thanks!


solution

If you want all of the flexbox items to have the same width, you could add flex-basis: 100%:

Updated Example

.flex-item {   background: tomato;   margin: 10px 5px;   color: white;   font-weight: bold;   font-size: 1.5em;   text-align: center;   flex-basis: 100%;   overflow: hidden;
}