Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

CSS3 box-align property

CSS3 box-align property

Example

Use both box-align and box-pack centering properties on the child elements in a div:

div

{

width:350px;

height:100px;

border:1px solid black;

/* Internet Explorer 10 */

display:-ms-flexbox;

-ms-flex-pack:center;

-ms-flex-align:center;

/* Firefox */

display:-moz-box;

-moz-box-pack:center;

-moz-box-align:center;

/* Safari, Opera, and Chrome */

display:-webkit-box;

-webkit-box-pack:center;

-webkit-box-align:center;

/* W3C */

display:box;

box-pack:center;

box-align:center;

}

Try it »

There are more examples at the bottom of this page.


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Currently no major browser supports the box-align property.

Internet Explorer 10 supports it through the private property -ms-flex-align.

Firefox supports it through the private property -moz-box-align.

Safari and Chrome support it through the private property -webkit-box-align.

**Note:** Internet Explorer 9 and earlier versions do not support flexbox.


Property definition and usage

The box-align property specifies how the child elements of a box are aligned.

Default value: stretch
Inherited: no
Version: CSS3
JavaScript syntax: object.style.boxAlign="center"

Syntax

box-align: start|end|center|baseline|stretch;

Value Description
start For boxes with a normal direction, the top edge of each child element is placed along the top of the box. For reverse boxes, the bottom edge of each child element is placed along the bottom of the box
end For boxes with a normal direction, the top edge of each child element is placed along the bottom of the box. For reverse boxes, the bottom edge of each child element is placed along the top of the box
center Any extra space is divided evenly, with half the child elements placed above and the remaining child elements placed in the other half
baseline If both thebox-orientis inline single-axis or horizontal, all child elements are aligned along their baseline
stretch Child elements are stretched to fill the containing block

Online example

Change the box alignment value of an element
This example demonstrates how to use JavaScript to change the box-align value of an element.