You are here: Reference > JavaScript > client-side > style handling > properties > browser specific extensions > MozBoxAlign

MozBoxAlign style property | webkitBoxAlign style property

Browser support:
MozBoxAlign
webkitBoxAlign
Specifies or retrieves how child elements of the box are aligned, when the size of the box is larger than the total size of the children.
Only works for box objects. An element is a box object if the display property of the element has the value of -moz-box (-webkit-box) or -moz-inline-box (-webkit-inline-box).

Syntax:

object.MozBoxAlign;
object.webkitBoxAlign;
You can find the related objects in the Supported by objects section below.
MozBoxAlign: This property is read/write.
webkitBoxAlign: This property is read/write.
CSS page for this property: -moz-box-align

Possible values:

The type of this property is string.
 One of the following values: 
baseline
This value only applies to horizontally oriented boxes.
center
Extra space is split equally along each side of the child elements, resulting in the children being placed in the center of the box.
end
Child elements are placed on the right or bottom edge of the box.
inherit
Takes the value of this property from the computed style of the parent element.
start
Child elements are aligned starting from the left or top edge of the box.
stretch
The child elements are stretched to fit the size of the box.
Default: stretch.

Example HTML code 1:

This example illustrates the use of the -moz-box-align and the -webkit-box-align properties:
<head>
    <style>
        .alignStart {
            height: 50px;
            border: 5px solid red;

            display: -moz-inline-box;
            display: -webkit-inline-box;
            -moz-box-align: start;
            -webkit-box-align: start;
        }
        .alignEnd {
            height: 50px;
            border: 5px solid red;
            
            display: -moz-inline-box;
            display: -webkit-inline-box;
            -moz-box-align: end;
            -webkit-box-align: end;
        }
    </style>
</head>
<body>
    <div class="alignStart">
        box-align: start
    </div>
    <div class="alignEnd">
        box-align: end
    </div>
</body>
Did you find this example helpful? yes no

Example HTML code 2:

This example illustrates the use of the MozBoxAlign and webkitBoxAlign properties in JavaScript:
<head>
    <style>
        .example {
            display: -moz-inline-box;
            width: 250px;
            height: 100px;
            border: 5px solid red;
            -moz-box-align: baseline;
        }
    </style>

    <script type="text/javascript">
        function ChangeBoxAlign (selectTag) {
            // Returns the index of the selected option
            var whichSelected = selectTag.selectedIndex;

            // Returns the selected option's text
            var boxAlign = selectTag.options[whichSelected].text;

            var div = document.getElementById ("myDiv");

            if ('MozBoxAlign' in div.style) {
                div.style.MozBoxAlign = boxAlign;
            } else if ('webkitBoxAlign' in div.style) {
                div.style.webkitBoxAlign = boxAlign;

                // solve refresh problems
                div.className = "";
                div.focus ();
                div.className = "example";
            } else {
                alert ("Your browser doesn't support this example!");
            }
        }
    </script>
</head>
<body>
    <div class="example" id="myDiv">
        <b>first elem </b>
        <i>second elem</i>
    </div>

    <select onchange="ChangeBoxAlign (this);" size="6">
        <option selected="selected" />baseline
        <option />center
        <option />end
        <option />inherit
        <option />start
        <option />stretch
    </select>
</body>
Did you find this example helpful? yes no

Supported by objects:

Related pages:

External links:

User Contributed Comments

Post Content

Post Content