10th Day: Adaptive Height _ Basic Tutorial

Source: Internet
Author: User
If we want to add a line footer at the end of the 3 column layout, put the information like copyright. You encounter a problem that must be aligned at the bottom of the 3 column. In table layout, we use a large table nested small table method, it is convenient to all three column, and with div layout, three columns independently dispersed, the content is different, it is difficult to align. We can actually Nest Div, put three columns into a div, and do the bottom alignment. Here is the implementation example (a white background box simulates a page):

Body here is #header{margin:0px; border:0px; BACKGROUND: #ccd2de; width:580px; height:60px;} Here is #mainbox {margin:0px; width:580px; BACKGROUND: #FFF; } contains the #menu, #sidebar和 #content here is #menu{float:right; margin:2px 0px 2px 0px; padding:0px 0px 0px 0px; width:400px; BACKGROUND: #ccd2de; }

Here is #sidebar{Float:left; margin:2px 2px 0px 0px; padding:0px; BACKGROUND: #F2F3F7; width:170px; }, background color with #main background

Here is #content{float:right; margin:1px 0px 2px 0px; padding:0px; width:400px; BACKGROUND: #E0EFDE;}

Here is the main content, automatically adapted to the height of the content

Here is the main content, automatically adapted to the height of the content

Here is the main content, automatically adapted to the height of the content

Here is #footer{Clear:both; margin:0px 0px 0px 0px; padding:5px 0px 5px 0px; BACKGROUND: #ccd2de; height:40px; width:580px; }。

The main code of the page for this example is as follows:







The specific style sheet is written in the appropriate section. The focus is on the #mainbox layer nesting #menu, #sidebar和 #content three layers. When the content of #content increases, #content的高度就会增高, while the height of #mainbox will open, #footer层就自动下移. This allows for a high degree of self-adaptation.

Also noteworthy is: #menu和 #content are floating on the right side of the page "Float:right;", #sidebar是浮动在 the #menu layer to the left "float:left;", this is the floating method positioning, you can also use absolute positioning to achieve this effect.

Another problem with this approach is that the background of the side-column #sidebar cannot be 100%. The general solution is to fill the body with the background color. (You cannot use the background color of #mainbox because the background color of #mainbox in browsers such as Mozilla is invalid.) )

Well, the main frame has been built, and the rest of the work is just a building blocks. If you want to try another layout, it's recommended to look at the following articles:

    • CSS Layout 16 examples
    • Onestab: Three-column composite layout demo
    • Onestab: Free stretch of the three-column layout

Tips:[onestab's "p.i.e" topic] There are more wonderful introduction, recommend to see.

  • 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.