CSS implementation left div adaptive width, right width fit to left

Source: Internet
Author: User

Use BFC: the right box triggers the BFC so that it does not overlap the floating box area, so the width is recalculated.
1 <style>2 . Box{width:900px;margin:0 Auto;Background-color:#eee; }3 . Left{Min-width:200px;float: Left;Background-color:Yellow;Height:60px;}4 . BFC{Background-color:Green; }5 . Right{Display:Inline-block;Margin-left:20px;Background-color:Red;Height:60px;}6 </style>7 <Divclass= "box">8     <Divclass= "Left">9 I'm a self-adapting width box, min-width:200px.Ten     </Div> One     <Divclass= "BFC"> A         <Divclass= "Right"> - I'm a self-adapting width, covered with the rest of the width -         </Div> the     </Div> - </Div>

Effect

Add:

BFC Translation is a block-level formatting context, similar to Haslayout, but Haslayout is a proprietary property of an older version of IE, which represents the elements themselves that organize and calculate their own content. BFC is equivalent to a separate rendering unit, and the inner and outer elements do not affect each other. I Overflow:hidden trigger BFC here, using a feature of the BFC layout, where the BFC area does not overlap with the floating box. BFC has many features, there are many trigger ways, interested students can Google in-depth understanding of the next

CSS implementation left div adaptive width, right width fit to left

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.