Flex and Grid
Flex
.wrapper { display: flex; } ``` d.wrapper { display: flex; height: 100vh; flex-direction: row; justify-content: flex-start; /* Horizontal alignment */ align-items: center; /* Vertical alignment */ }.wrapper { display: flex; height: 100vh; flex-direction: column; justify-content: space-between; /* Vertical alignment */ align-items: flex-start; /* Horizontal alignment */ }.box { width: 100px; height: 100px; background-color: peru; } .box:nth-child(2) { align-self: center; }.box: nth-child(2) { order: 1; /* Move right by 1 */ }.box: nth-child(1) { order: 2; /* Move right by 2 --> in front of last item */ } .box: nth-child(2) { order: 3; /* Move right by 3 --> rightmose */ }.wrapper { display: flex; flex-wrap: nowrap; /* wrap | wrap-reverse */ }.wrapper { display: flex; flex-direction: column; flex-wrap: wrap; } to: .wrapper { display: flex; flex-flow: column wrap; /* shorthand of flex-direction and flex-wrap */ }.wrapper { display: flex; flex-wrap: wrap; align-content: flex-start }
.box:nth-child(2) { background-color: tomato; flex-shrink: 2; }
Reference sites/docs
Last updated