CSS3 can be used to show the size of sub-elements in an equal or proportional manner. css3 is used to show the size of sub-elements.

Source: Internet
Author: User

CSS3 can be used to show the size of sub-elements in an equal or proportional manner. css3 is used to show the size of sub-elements.

The usage is similar to the Android: layout_weight attribute of android. It is similar to the usage in Android. It is easy to remember that most of the properties are not supported by all browsers currently, therefore, all attributes must be prefixed with "-moz-" and "-webkit-", which are supported by Firefox, Safari, Opera, and Chrome. Now, basically all CSS3 attributes should do this, that is, you must set at least three attributes. refer to the following example.

Parent container attributes:
Display: box; when this attribute is defined, margin: 0px auto is invalid when the sub-element is to be centered. text-align: center (layout_weight of the LinearLayout sub-control can take effect in Android, and display in css3 is set to box in a similar way)
Box-orient: horizontal (horizontal) | vertical (vertical) | inline-axis (horizontal) | block-axis (vertical) | inherit; (Android: orientation attribute in android)
Box-direction: normal (default) | reverse (reverse) | inherit;
Box-align (vertical alignment of the face container in the parent container): start (top) | end (bottom) | center | baseline | stretch (stretch ); (Android: gravity attribute in android)
Box-pack (horizontal alignment of the face container in the parent container): start (left) | end (right) | center | justify (horizontal equals parent container width ); (Android: gravity attribute in android)
Box-lines (specifies whether to display line breaks if the column exceeds the space in the parent box. Currently, no browser supports the box-lines attribute .) : Single | multiple;

Example:

Display: box;
Display:-moz-box;
Display:-webkit-box;
Box-orient: horizontal;
-Moz-box-orient: horizontal;
-Webkit-box-orient: horizontal;


Sub-container attributes:
Box-flex (specifies whether the child element of the box is scalable .) : Value (a scalable row of an element. Flexibility is relative. For example, the sub-elements with box-flex 2 are twice the sub-elements with box-flex 1 .), When the elements set the specific width, height, and margin, other elements subtract the specific values from the parent container and then distribute them proportionally.

For example, if the parent container sets the width to pixel PX and the box-orient is defined as horizontal division, that is, horizontal or inline-axis, the sub-elements define box-flex as 1, 2, 3, the width of the first sub-element is 200px, the second is 400px, and the third is 600px. If the second child element defines a width of 1200 PX, the first and third box-flex are defined as 1 and 2 respectively, the first width will be (300) * 1/(1 + 2) = 300px, the third is 600px, and the second is 300px. If margin is set, we need to subtract it and then divide it.

(Android: layout_weight attribute in android)

Example:

Box-flex: 3;
-Moz-box-flex: 3;
-Webkit-box-flex: 3;


CSS3: how can we make the width of a child element adaptive to its absolute positioning?

<Td id = "ttttt" style = "position: relative; display: block;"> </td> and then increase the height of ttttt.

How does css3 use a selector to define a child element style divided by 3 to zero?

It means that the remainder is 0, and css3 cannot do it. Use jquery to judge it, or write the row elements in the server language. Each of the three elements gives a different css style.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.