flex佈局問題
阿新 • • 發佈:2020-08-28
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> <style> .father{ display: flex; flex-direction: column; } .son{ height: 50px; width: 50px; background: #000; } .son:nth-child(1){ align-self: flex-start; } .son:nth-child(2){ align-self: center; } .son:nth-child(3){ align-self: flex-end; } </style> </head> <body> <div class="father"> <div class="son"></div> <div class="son"></div> <div class="son"></div> </div> </body> </html>
flex
屬性是flex-grow
,flex-shrink
和flex-basis
的簡寫,預設值為0 1 auto
。後兩個屬性可選。