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-align attribute to control the layout of child elements in CSS

2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

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

This article mainly introduces how to use box-align attributes to control the layout of sub-elements in CSS. It is very detailed and has a certain reference value. Friends who are interested must read it!

Box-align description

The box-align attribute, which is used when specifying the vertical arrangement of child features within an element.

In cases where the container element is much larger than the child element, using the box-align attribute, you can specify the sort order of the child element, and you can specify how the child element is represented.

In addition, the vertical arrangement can be interpreted as the default value of the configuration direction of the child elements within the element is horizontal, and the vertical direction is arranged after using this attribute. You can also use box-orient:vertical to set the orientation of child elements.

Attribute value

Start: standard orientation element, the top of each sub-element is arranged along the top of the element, the remaining positions are sorted down, and the elements in the opposite direction are sorted along the lower end, and the remaining positions are sorted up.

End: standard directional element, the lower end of each sub-element is arranged along the lower end of the element, the remaining positions are sorted upward, and in the opposite direction, the elements are sorted along the upper end, and the remaining positions are sorted down.

Center: the remaining space is allocated equally.

In the case of baseline:inline-axis and horizontal, all child elements are arranged in baseline configuration

Stretch: each child element is automatically sorted according to the height of the container element (default)

About centering

The original horizontal and vertical center is written as follows: height=line-height to achieve vertical center text-align to achieve horizontal center

Now use box-align to achieve vertical centering box-pack to achieve horizontal centering

Horizontal and vertical center

Instance code

Box-align div.prefix_sample1 {width:500px; height:100px; background-color:yellow; display:-moz-box; display:-webkit-box; display:-o-box; display:-ms-box;-moz-box-align:start;-webkit-box-align:start;-o Mustang box color start;-ms-box-align:start;} div.prefix_sample2 {width:500px; height:100px; background-color:yellow Display:-moz-box; display:-webkit-box; display:-o-box; display:-ms-box;-moz-box-align:end;-webkit-box-align:end;-Oftel Boxhouse;-ms-box-align:end;} div.prefix_sample3 {width:500px; height:100px; background-color:yellow; display:-moz-box; display:-webkit-box; display:-o-box Display:-ms-box;-moz-box-align:center;-webkit-box-align:center;-Oftel box house;-ms-box-align:center;} div.prefix_sample4 {width:500px; height:100px; background-color:yellow; display:-moz-box; display:-webkit-box; display:-o-box; display:-ms-box;-moz-box-align:baselinebaseline;-webkit-box-align:baselinebaseline -ms-box-align:baselinebaseline; box moz-box-align:stretch; webkit-box-align:stretch; baseline;-ms-box-align:baselinebaseline;} div.prefix_sample5 {house-moz-box-align:stretch;-webkit-box-align:stretch;-o Mustok box house lights Vista;-ms-box-align:stretch } div.aka {background-color:red;} div.midori {background-color:green;} div.ao {background-color:blue;} box-align:start; abcde box-align:end; abcde box-align:center; abcde box-align:baselinebaseline; abcde box-align:stretch Abcde

Example diagram

The above is all the content of the article "how to use the box-align attribute to control the layout of sub-elements in CSS". Thank you for reading! Hope to share the content to help you, more related 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