May 05, 2021 CSS Reference Manual
By using the box-align and box-pack properties, the child elements of the center div box:
div { width:350px; height:100px; border:1px solid black; /* Firefox */ display:-moz-box; -moz-box-pack:center; -moz-box-align:center; /* Safari、Opera 以及 Chrome */ display:-webkit-box; -webkit-box-pack:center; -webkit-box-align:center; /* W3C */ display:box; box-pack:center; box-align:center; }
There are more instances at the bottom of the page.
There is currently no browser that supports the box-align property.
Firefox supports alternative -moz-box-align properties.
Safari, Opera, and Chrome support alternative -webkit-box-align properties.
The box-align property specifies how the child elements of the box are aligned.
Default: | stretch |
---|---|
Inheritance: | no |
Version: | CSS3 |
JavaScript syntax: | object .style.boxAlign="center" |
box-align: start|end|center|baseline|stretch;
Value | Describe | Test |
---|---|---|
start |
For a box in the normal direction, the top edge of each child element is placed along the top edge of the box. For boxes in the opposite direction, the bottom edge of each child element is placed along the bottom edge of the box. |
Test |
end |
For a box in the normal direction, the bottom edge of each child element is placed along the bottom edge of the box. For boxes in the opposite direction, the top edge of each child element is placed along the top edge of the box. |
Test |
center | Split the excess space equally, half above the child element and the other half below the child element. | Test |
baseline | If the box-orient is inline-axis or horizon, all child elements are aligned with their baselines. | Test |
stretch | Stretch child elements to fill the containing block |