There are four methods to meet the requirements of the div adaptive height and the height of the left and right:
1. The visual simulation background refers to the parent container setting background and vertical loop to simulate an illusion. It is A set of BC, and the section with insufficient BC is replaced by the background of. . Side {overflow: hidden; background: # ddc ;}< br/>. left {float: left; width: 40% ;}< br/>. right {float: right; width: 60%; background: # cdd ;} <Div class = "side"> <br/> <div class = "left"> left </div> <br/> <div class = "right"> right <br /> <br/> </div> <br /> </div>2. JAVASCRIPT . Main {overflow: hidden; background: # ddc ;}< br/>. left {float: left; width: 40% ;}< br/>. right {float: right; width: 60%; background: # cdd ;} <Div class = "main"> <br/> <div class = "left"> left </div> <br/> <div class = "right"> right <br /> <br/> </div> <br /> </div> <br/> <mce: script type = "text/javascript"> <br/> <! -- <Br/> document. getElementById ("right "). style. height = document. getElementById ("main "). scrollHeight + "px"; document. getElementById ("left "). style. height = document. getElementById ("main "). scrollHeight-2 + "px"; <br/> // --> </mce: script>3. Positive padding negative margin. The biggest drawback is that the anchor cannot be placed in it. If a page Jump encounters an anchor, the page above the anchor will not be displayed. . Side {overflow: hidden; background: # ddc ;}< br/>. left {float: left; width: 40% ;}< br/>. right {margin-bottom:-32767padding-bottom: 32767 float: right; width: 60%; background: # cdd ;} <Div class = "side"> <br/> <div class = "left"> left </div> <br/> <div class = "right"> right <br /> <br/> </div> <br /> </div>4. Relative Position Method <Div style = "border-right: solid 180px # f00; background: #000; color: # fff" mce_style = "border-right: solid 180px # f00; background: #000; color: # fff "> <br/> <div style =" width: 180px; float: right; position: relative; right:-180px; "> <br/> <br/> </div> </p> <div style = "clear: both; height: 0; overflow: hidden; "> <br/> </div>
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