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 display box in css3

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

Share

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

Css3 how to use display box, many novices are not very clear about this, in order to help you solve this problem, the following editor will explain in detail for you, people with this need can come to learn, I hope you can gain something.

One of the scenarios is as follows:

If we want to split the space occupied by the outer in different proportions with the internal level of 123elements, we might float the 123elements or set the display property to inline-block, and then set the width percentage to the width attribute to split the outer.

After using display:box, you can do this:

The code is as follows:

# outer {

Width:600px

Height:100px

Display:-moz-box

Display:-webkit-box

Display:box

}

# a1 {

Background:blue

-moz-box-flex:1

-webkit-box-flex:1

Box-flex:1

}

# a2 {

Background:green

-moz-box-flex:2

-webkit-box-flex:2

Box-flex:2

}

# a3 {

Background:yellow

-moz-box-flex:3

-webkit-box-flex:3

Box-flex:3

}

The effect is as follows:

The box-flex attribute in the child element is the percentage of the element, and for this attribute to take effect, the parent element must set display:box. Take A3 as an example, if A3 sets box-flex to 3, then its width is 600 * (3 / (1 / 2 / 3)) as 300px.

If one of the child elements has a fixed-width 100px set, the remaining 500px will participate in the scaling rules.

Is it helpful for you to read the above content? If you want to know more about the relevant knowledge or read more related articles, please follow the industry information channel, thank you for your support.

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