问题
What is the difference between these two values? I've tested numerous examples and they just give the exact same result... Can someone please give me an example where flex-basis: auto;
does not give the same result as flex-basis: 0;
回答1:
"0" and "auto" flex-basis will be different in most if not all situations: numeric values are interpreted as specific widths, so zero would be the same as specifying "width: 0"
(and thus will collapse the element to its smallest possible width given the content, or to zero itself if its overflow is hidden.)
.f {display:flex}
.f div {border:1px solid}
.zero {flex-basis: 0}
.auto {flex-basis: auto}
<div class="f">
<div class="zero">This is flex-basis zero</div>
</div>
<div class="f">
<div class="auto">This is flex-basis auto</div>
</div>
来源:https://stackoverflow.com/questions/47578958/the-difference-between-flex-basis-auto-and-0-zero