flex-basis
属性默认值:auto
默认值表示:项目的
flex-basis
属性值为项目的width
属性值。css
width
属性默认值: auto
默认值表示:项目的
width
属性值为项目中内容的实际宽度。html
flex-basis
属性值 与 项目中内容的实际宽度 比较后得到。flex
项目的实际宽度width
属性为auto
flex-basis
属性值width
属性值 <div class="row"> <div class="col"></div> <div class="col"> <div style="width: 250px;"></div> </div> </div>
.row { display: flex; width: 800px; height: 100px; } .row > .col:nth-child(1) { background: red; width: 100px; flex-basis: auto; } .row > .col:nth-child(2) { background-color: green; width: auto; flex-basis: 100px; }
250px
flex-basis
属性值:100px
250px
flex-basis
属性值flex-basis
属性值 <div class="row"> <div class="col"></div> <div class="col"> <div style="width: 50px;"></div> </div> </div>
.row { display: flex; width: 800px; height: 100px; } .row > .col:nth-child(1) { background: red; width: 100px; flex-basis: auto; } .row > .col:nth-child(2) { background-color: green; width: auto; flex-basis: 100px; }
50px
flex-basis
属性值:100px
100px
width
属性不为auto
overflow: hidden
flex-basis
属性值width
属性值 > 项目的flex-basis
属性值width
属性值 <div class="row"> <div class="col"></div> <div class="col"> <div style="width: 250px;"></div> </div> </div>
.row { display: flex; width: 800px; height: 100px; } .row > .col:nth-child(1) { background: red; width: 100px; flex-basis: auto; } .row > .col:nth-child(2) { background-color: green; width: 200px; flex-basis: 100px; }
250px
flex-basis
属性值:100px
width
属性值:200px
200px
flex-basis
属性值width
属性值 < 项目的flex-basis
属性值flex-basis
属性值 <div class="row"> <div class="col"></div> <div class="col"> <div style="width: 250px;"></div> </div> </div>
.row { display: flex; width: 800px; height: 100px; } .row > .col:nth-child(1) { background: red; width: 100px; flex-basis: auto; } .row > .col:nth-child(2) { background-color: green; width: 50px; flex-basis: 100px; }
250px
flex-basis
属性值:100px
width
属性值:50px
100px
flex-basis
属性值width
属性值 > 项目的flex-basis
属性值) 或者 (项目的width
属性值 < 项目的flex-basis
属性值)flex-basis
属性值 <div class="row"> <div class="col"></div> <div class="col"> <div style="width: 50px;"></div> </div> <div class="col"> <div style="width: 50px;"></div> </div> </div>
.row { display: flex; width: 800px; height: 100px; } .row > .col:nth-child(1) { background: red; width: 100px; flex-basis: auto; } .row > .col:nth-child(2) { background-color: green; width: 200px; flex-basis: 100px; } .row > .col:nth-child(3) { background-color: blue; width: 50px; flex-basis: 100px; }
状况一:flex
50px
flex-basis
属性值:100px
width
属性值:200px
100px
状况二:spa
50px
flex-basis
属性值:100px
width
属性值:50px
100px
overflow: hidden
flex-basis
属性设置的宽度。