The box-sizing: border-box
is used to change the default CSS box model used to calculate width
and height
of the elements.
So would be like this:
But that doesn't happen in flex-grow
, but in flex-basis
Here is a good tutorial about flexbox
So you can use flex:0 20%
instead of flex:1
,
.container {
display: flex;
flex-direction: row;
align-items: center;
width: 100px;
}
.container .block {
height: 28px;
flex: 0 20%;
border: 1px solid black;
box-sizing: border-box;
}
.container .block.selected {
border: 3px solid blue;
}
<div class="container">
<span class="block">0</span>
<span class="block">1</span>
<span class="block selected">2</span>
<span class="block">3</span>
<span class="block">4</span>
</div>
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…