Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to use the box-pack attribute in css

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

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!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report