i read mdn and googled other docs. i understand that flex-basis is higher priority than width, and than content computed width.
but seems the above only applies when flex-basis is >= content min width. specifically (note i used "width", not "min-width"),
- if i set flex-basis = 0, the div element width wouldn't become 0 (seems it's min content width). and you can change flex-basis to other small value like 2px, the final width is still min content width.: https://jsfiddle.net/afx3e14m/
<div class='a'>
<div class='b'>
this is just a random statment
</div>
</div>
.a{display: flex;}
.b {flex: 0 0 0;
border: 1px solid red;}
- but if set width = 0, the div element width is now 0: https://jsfiddle.net/afx3e14m/1/
.a{display: flex;}
.b {flex: 0 0 auto;
width:0;
border: 1px solid red;}
moreover, if you apply flex-basis and width at the same time, with width smaller than flex-basis, then flex-basis will take effect even though it's smaller than min content width: https://jsfiddle.net/afx3e14m/2/
.a{display: flex;}
.b {flex: 0 0 2px;
width:0px;
border: 1px solid red;}
so this is really confusing. seems it's not as simple as "flex-basis takes priority, and then fall back to width if not specified". it's more like, when flex-basis is wider than min content width, this is true. but when narrower, whether flex-basis would be effective depends on the existence of a smaller width. if width is larger than flex-basis and smaller than min content width, then width will be applied instead of flex-basis.
i was wondering if any developer can confirm this or point me to some really good documentations/tutorials. things like MDN are good, but couldn't find the comprehensive logic about flex-basis there. thanks.