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
屬性設置的寬度。