CSS height, width adaptive layout

Source: Internet
Author: User

<! DOCTYPE html>
<meta charset= "Utf-8"/>
<title>test</title>
<style>
*{
margin:0;
padding:0;
Color: #FFF;
}
. a{
Background: #FF0000;
width:100%;
Float:left;
margin-right:-100px;
}
. b{
Background: #006699;
width:100px;
Float:right;
}
. c{
Background: #006666;
margin-right:100px;
}
</style>
<body>
<div class= "A" ><div class= "C" > Left </div></div><div class= "B" > Right </div>
</body>
The above code is the right fixed width, the left adaptive width, margin-right:-100px also shows that the size of the floating element is affected by the margin, above a width is 100% width minus 100px
Here adaptive is the use of the size of the floating element can be adjusted by margin, if given margin-right negative, then the right will be trimmed to the corresponding width, so that the right side of the fixed width of the layout to leave the same size space
This visually is fixed floating on the right, the left adaptive float, but in fact, if there is no C element, but simply put the text into a, the text will run to the bottom of B, so I add C to a, and do not specify width, horizontal right margin to 100px, so that the text will not be overwritten, We can test it.

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.