CSS3 box learning and css3box Learning

Source: Internet
Author: User

CSS3 box learning and css3box Learning

The box style provided by CSS3 enables the flexible layout of elements inside the box. We don't need to use float or display: inline to arrange block elements horizontally (box-orient can do this ), you can also calculate the width or percentage of each block to achieve the same balance (box-flex can do it ). So, use sister paper boldly. Set the display: box for the parent element to layout the internal block-level child elements. In this case, the internal elements are arranged in the inline element arrangement mode, but the width and height can be set. Use the following style for the parent box:

1. box-orient

Specifies the arrangement of internal sub-elements, including

  • Vertical
  • Horizontal
  • Inline-axis
  • Block-axis
2. box-align

Specifies the vertical arrangement of internal child elements:

  • Center: center vertically in the parent box
  • Start: arranged from the top of the parent Element
  • End: Align the bottom of the parent Element
  • Stretch: vertically stretched to fill the entire parent Element
  • Baseline
3. box-pack

Horizontal Alignment
Start: left aligned
Center: Align child elements horizontally
Justify: aligned at both ends
End: right alignment

Note: box-align and box-pack Alignment Methods are related to box-orient settings.

4. box-direction

The sequence of sub-boxes.

5. box-sizing

Set which parts of the box are included in width:

  • Content-box: width = content area
  • Border-box: width = content area + padding + border
6. box-flex

This attribute must be set in the child element to allocate the remaining width and height of the parent element (when it is set to vertical layout). To set this attribute, display must be set by the parent element: box is useful.
Understanding of remaining width:

Parent container width-Sub-container fixed width (priority)/sub-container content width-Sub-container margin & border & padding

Box-align and box-pack also apply to inline elements, while box-flex does not apply to inline elements.

A strange phenomenon is found. When the img and input labels are put together, the box-align: center cannot be used to vertically center the input, while the vertical-align: after the middle. Emma should be related to vertical-align, rather than controlled by box-align.

Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.