Left fixed in CSS, right adaptive

Source: Internet
Author: User

Let's talk about a question I started working on.

I remember in the Pacific Network interview, the interviewer gave me such a problem: there is an outer div in the middle of the left and right two Div requires Div

          1. Only tell you the width;       2. Only tell you the height; 3. Width and height tell you; (I summed up the possible 3 ways)
          HTML:
<Divclass= "Container"><Divclass= "Left">Left Fixed width 200px</Div><Divclass= "Right">Right adaptive</Div></Div>
          No1: Method One
 .container  {width :  100% ; }.left  {color : red ;  background :  Gray ;  float :  left ; :  100px }  on the left side of >// {color : red ;  background :  blue ;  Margin-left :  -200px ;} //right-hand div  

No2: Method Two

. Container{width:100%;}. Left{width:200px;background:#fcc;position:Absolute; Left:0;Z-index:1}. Right{width:100%;background:#ccc;position:Absolute; Left:0}

No3: Method Three

 .container  {width : 100% }.left  { Background-color :  green ;  float :  left ; :  200px ;  Margin-right :  -100% ; }.right  { float :  left ; :  100% ; margin-left :  200px ;  Background-color : blue ; }

No4: Method Four

. Container {width:100%} . Left {position: absolute; top:0; Left:0; width:200px; background: #ff0;} . Right { margin-left: 200px; background: #f0f;}

No5: Method 5

. Container{width:100%}. Left{position:Absolute;Top:0; Left:0;width:200px;background:Blue;}. Right{position:Absolute;Top:0; Left:200px;width:100%;rigth:0;background:Red;}

In fact there are many ways to achieve (other I do not bother to write), so-called all roads to Rome, cough, do not like to spray

Left fixed in CSS, right adaptive

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.