CSS properties apply a hodgepodge of bugs (follow up to update)

Source: Internet
Author: User

One, the use of the flex layout when the pit:

  1, the common distribution of the flex layout, left a given width, the right to fill the remaining space, but when the right side of the text content, will be crowding the left space, the left can not be displayed in accordance with a fixed width.

<style>. Father{Display:Flex;width:500px;Height:200px;        }. Left{width:200px;Background-color:Green;        }. Right{Flex-grow:1;Background-color:Red;        }    </style>    <Body>        <Divclass= "Father">            <Divclass= "Left">Left left and left left side</Div>            <Divclass= "Right">Right</Div>        </Div>    </Body>

The correct width is displayed as follows:

    

However, when the text in the right red box changes:

    

Obviously when the right text increases, the left side is compressed when the remaining space is squeezed, and the workaround is as follows:

1) Add width to the right "width:0;", specify width 0

. right{            flex-grow:1;            background-color:red;        }

2) Add Flex-basis property to the element that has the Flex-grow property set

. right{            flex-grow:1;            background-color:red;            flex-basis:0%;        }

2. The difference between basis and width in flex layout, reference link HTTPS://WWW.JIANSHU.COM/P/17B1B445ECD4

CSS properties apply a hodgepodge of bugs (follow up to update)

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.