Get the App
SLTechnology News&Howtos  ›  Development  › 

How to use the box-pack attribute in css

Shulou Source: shulou.com Published: 2022-06-01 12:17:25 10月04日 Update

This article mainly shows you "how to use the box-pack attribute in css", the content is easy to understand, clear, hope to help you solve your doubts, the following let the editor lead you to study and learn "how to use the box-pack attribute in css" this article.

Definition and usage of cssbox-pack attribute

1.box-pack attribute is a new attribute of css3, which is used to specify where to place child elements when the box is larger than the size of child elements. At present, mainstream browsers do not support this attribute, but some browsers have their own private attributes to achieve the effect of box-pack attributes.

2.InternetExplorer10 can use the-ms-flex-packproperty attribute instead of supporting the box-pack attribute, which was not supported in previous versions of InternetExplorer10. Firefox kernel browsers can use the private attribute-moz-box-pack attribute instead of supporting the box-pack attribute. Safari, Opera, and Chrome browsers can use the private property-webkit-box-pack attribute instead of supporting the box-pack attribute

Cssbox-pack attribute syntax format

Box-pack:start/end/center/justify

Attribute value description

Start: for normal-oriented boxes, the first child element on the left edge is placed on the left (the last child element after all the extra space is placed). For reverse boxes, the last child at the right edge is placed on the right (the first child before all extra space is placed)

End: for a normally oriented boxes, the right edge of the last child element is placed on the right (the first child element before all the extra space is placed). For reverse boxes, the left edge of the first child is placed on the left (the last child element after all the extra space is placed)

Center: the extra space is evenly divided into two halves, with the first half placing the first child element and the other half placing the last child element

Justify: the extra space is evenly allocated to each child element

Case study

Css3box-pack attribute notes

Body {background-color:#aaa;}

Div {width:400px;height:100px;border:1pxsolidmediumvioletred;}

.box1 {

Display:box;/*W3C*/

Display:-ms-flexbox;/*InternetExplorer10*/

Display:-moz-box;/*Firefox*/

Display:-webkit-box;/*Safari,Opera,andChrome*/

Box-pack:center;/*W3C*/

-ms-flex-pack:center;/*InternetExplorer10*/

-moz-box-pack:center;/*Firefox*/

-webkit-box-pack:center;/*Safari,Opera,andChrome*/

}

.box2 {

Display:box;/*W3C*/

Display:-ms-flexbox;/*InternetExplorer10*/

Display:-moz-box;/*Firefox*/

Display:-webkit-box;/*Safari,Opera,andChrome*/

Box-pack:justify;/*W3C*/

-ms-flex-pack:justify;/*InternetExplorer10*/

-moz-box-pack:justify;/*Firefox*/

-webkit-box-pack:justify;/*Safari,Opera,andChrome*/

}

one

two

one

two

The above is all the content of the article "how to use the box-pack attribute in css". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Attributes elements size space support browser edge browse content article private available through right direction learning help general mainstream kernel child Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Linux MySQL Huawei Shulou Information Shulou Technology