Align the <div> elements of the elastic box in the center:
1 <style>2 #main{3 width:220px;4 Height:300px;5 Border:1px solid Black;6 Display:-webkit-flex; /*Safari*/7 -webkit-align-items:Center; /*Safari 7.0+*/8 Display:Flex;9 Align-items:Center;Ten } One A #main Div{ - -webkit-flex:1; /*Safari 6.1+*/ - Flex:1; the } - </style> - </Head> - <Body> + - <DivID= "Main"> + <Divstyle= "background-color:coral;">RED</Div> A <Divstyle= "Background-color:lightblue;">BLUE</Div> at <Divstyle= "Background-color:lightgreen;">Green div with more content.</Div> - </Div> - - <P><b>Attention:</b>Internet Explorer 10 and earlier browsers do not support the Align-items property.</P> - <P><b>Attention:</b>This property is supported by the-webkit-align-items property in Safari 7.0 and later.</P> - in </Body>
Operation Result:
Property value
CSS syntax
1 Align-items:stretch|center|flex-start|flex-end|baseline|initial|inherit;
CSS Align-items Properties