Created by CyanHall.com
on 11/13/2020
, Last updated: 04/30/2021.
πΒ Β Star me if itβs helpful. Interactive demo of flexbox. Buttons are clickable, container are resizable.
The CSS property of A:
πΒ Β Star me if itβs helpful. Interactive demo of flexbox. Buttons are clickable, container are resizable.
A
B
C
D
Flex Container
display
:flex
,inline-flex
flex-direction
:justify-content
(The layout for flex direction)align-items
(The layout for cross flex direction, block C is setalign-items: baseline
)flex-wrap
(Adjust the bottom-right corner to resize the Demo)flex-flow
=flex-direction
+flex-wrap
, eg:flex-flow: row wrap
.align-content
(Only has an effect with more than one line of content)
Flex Item:
The CSS property of A:
order
: 0align-self
: (override Flex Container'salign-items
)flex-basis
:
When container'sflex-direction
isrow
: override A'swidth
.
When container'sflex-direction
iscolumn
: override A'sheight
.
flex-grow
: (Define how to fill extra space)flex-shrink
: (Initialwidth: 100px
,height: 100px
, define how to shrink inside oversize space)
Demo Source Codes
<div class="cyanhall-container">
<div class="cyanhall-item cyanhall-item-a">A</div>
<div class="cyanhall-item cyanhall-item-b">B</div>
<div class="cyanhall-item cyanhall-item-c">C</div>
<div class="cyanhall-item">D</div>
</div>
.cyanhall-container {
resize: both;
overflow: auto;
display: flex;
border: 1px solid #ddd;
border-radius: 3px;
height: 100px;
align-items: flex-start;
}
.cyanhall-item {
margin: 2px;
min-width: 40px;
min-height: 40px;
background-color: #4a8fe2;
color: white;
display: flex;
justify-content: center;
align-items: center;
}
.cyanhall-item-c {
align-items: baseline;
}
More