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

CSS3 box-pack property

CSS3 box-pack 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, Chrome, and Opera */

display:-webkit-box;

-webkit-box-pack:center;

-webkit-box-align:center;

/* W3C */

display:box;

box-pack:center;

box-align:center;

}

Try it »


Browser support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

Currently no major browser supports the box-pack property.

Internet Explorer 10 supports it instead using the -ms-flex-pack property.

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

Safari, Opera, and Chrome support it through the private property -webkit-box-pack.

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


Property definition and usage

The box-pack property specifies how child elements of a box are positioned when they are smaller than the box.

This property specifies the horizontal position for a horizontal box and the vertical position for a vertical box.

Default value: start
Inherited: no
Version: CSS3
JavaScript syntax: object.style.boxPack="center"

Syntax

box-pack: start|end|center|justify;

Value Description
start For boxes with a normal direction, the first child element is placed at the left edge (all extra space is placed after the last child element). For reverse boxes, the last child element is placed at the right edge (all extra space is placed before the first child element)
end For boxes with a normal direction, the last child element is placed at the right edge (all extra space is placed before the first child element). For reverse boxes, the first child element is placed at the left edge (all extra space is placed after the last child element)
center The extra space is divided evenly into two halves, the first half placed before the first child element and the other half after the last child element
justify Extra space is distributed evenly to each child element