The indefinite width and adaptive of the layout

Source: Internet
Author: User

Indefinite width: Refers to the setting of any width, or width of the content is determined.

Adaptive: No matter how the other elements change, it doesn't have to be changed.

Proposition: setting indefinite width and adaptive

<Divclass= "Parent">     <Divclass= "Left">          <P>Left</P>    </Div>    <Divclass= "Right">          <P>Right</P>          <P>Right</P>    </Div></Div>

Scenario 1: Float+overflow

. left{   Float:left;   width:100px;                 . Left p{width:200px;}
margin-right:20px; }. right{ Overflow:hidden;}

Scenario 2: Table

Layout first
. parent{ display:table; width:100%; Table default width is the content, the sum of the width of each column is the total width of table table-layout:fixed; Improve the rendering speed, realize the layout priority}.left,.right{ Display:table-cell; Set to cell can not be set margin}.left{ width:100 px; padding-right:20px;}
Content first
. parent{ display:table; width:100%; Table default width is the content, the sum of the width of each column is table total width}.left,.right{ Display:table-cell; Set to cell can not be set margin}.left{ width:0.1%; padding-right:20px;}
. Left p{
width:200px;
}

Scenario 3: Flex

. parent{    Display:flex;}. left{    width:100 px;          . Left p{width:200px;}    margin-right:20px;}. right{    flex:1;                 Equivalent to flex:1 1 0;   The rest of the space is given right}

Additional: Multi-column variable width and adaptive

Set the width of the pattern to a consistent

The indefinite width and adaptive of the layout

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.