CSS3 flexible layout flexible flow (flex-flow) attribute details and Instances

Source: Internet
Author: User

CSS3 flexible layout flexible flow (flex-flow) attribute details and Instances

Elastic layout is a powerful layout method introduced by CSS3. It is used to replace some complex and error-prone hacks methods used by Web developers (such as using float for similar stream layout ).

Flex-flow is short for flex-ction and flex-wrap attributes. The syntax is as follows:

Flex-flow: |

Flex-direction: row (Initial Value) | row-reverse | column-reverse

Flex-wrap: nowrap (Initial Value) | wrap-reverse

Flex-direction defines the placement direction of an Elastic project in an elastic container. The default value is row, that is, the internal direction of the line (generally from left to right, but note that this is related to the writing mode ).

Flex-wrap defines whether to split rows so that the elastic project can be included by the container. *-Reverse indicates the opposite direction.

The combination of the flex-flow attribute determines the display mode of the elastic container in the main axis and cross axis directions. The following example intuitively illustrates the differences between attribute values:

 

.flex-container {    display: flex;}.flex-container.first {    flex-flow: row;}/* Initial value. Main-axis is   inline, no wrap. */.flex-container.second {    flex-flow: column wrap;    -webkit-flex-flow: column wrap;}/* Main-axis is block-direction (top to bottom)   and lines wrap in the inline direction (rightwards). */.flex-container.third {    flex-flow: row-reverse wrap-reverse;}/* Main-axis is the opposite of inline direction   (right to left). New lines wrap upwards. *//* other styles just for format */ul {    padding: 0;}li {    list-style: none;}.flex-container {    background: deepskyblue;    width: 200px;    height: 200px;    margin: 5px auto;}.flex-container.first {    height: 100px;}.flex-item {    background: tomato;    padding: 5px;    width: 80px;    height: 80px;    margin: 5px;    line-height: 80px;    color: white;    font-weight: bold;    font-size: 2em;    text-align: center;}h1 {    font-size: 22px;    text-align: center;}.flex-demo {    display: flex;}
In the preceding example, the default attribute "row" is used in the 1st auto-scaling item list and the row is not split. The width of the auto-scaling item is compressed as needed.
Column wrap is used in the 2nd lists, indicating that the direction of the spindle is from top to bottom, while that of the row splitting is from the inside (to the right ).
The 3rd lists use row-reverse wrap-reverse, indicating that the direction of the spindle is in the opposite direction of the line (from right to left), and the new line is split up.

Related Article

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.