Flex-按预期增长,而不是调整FLEX项目的大小。
flex-grow
flex-grow: 2
flex-grow: 1
.
.numbers { display: flex; flex-direction: column;}.row { display: flex; flex-direction: row; flex-grow: 1; justify-content: space-between;}.button { display: flex; flex-grow: 1; justify-content: center; align-items: center; margin: 5px; border-radius: 5px; border: 1px solid gray; background: rgba(255, 255, 255, 0.2); cursor: pointer;}.button#number0 { flex-grow: 2;}.button#colon { flex-grow: 1;}
<div class="numbers"> <div class="row"> <div class="button number" id="number1">1</div> <div class="button number" id="number2">2</div> <div class="button number" id="number3">3</div> </div> <div class="row"> <div class="button number" id="number4">4</div> <div class="button number" id="number5">5</div> <div class="button number" id="number6">6</div> </div> <div class="row"> <div class="button number" id="number7">7</div> <div class="button number" id="number8">8</div> <div class="button number" id="number9">9</div> </div> <div class="row"> <div class="button number" id="number0">0</div> <div class="button" id="colon">:</div> </div></div>
Smart猫小萌
叮当猫咪