Fantastic CSS layout-Multi-column height

Source: Internet
Author: User

What is a high-level layout?

Let's look at a case:

 

The main content of the page in is a two-column structure, the left column is used for navigation, and the right column is used to display the content. We can see that they have a common border with a separator in the middle. The height of the left and right columns is not fixed. In this case, the height of the two columns must be consistent. The height on the left increases, the height on the right increases, and the height on the right increases. The height on the left also increases, otherwise, the "fault" effect will appear. Here, the High-Level layout is designed to maintain the integrity of the border lines. In some cases, it may be used to maintain the integrity of the background and achieve the effect that the overall consistency is not missing.

Layout Scheme

There are several different methods for High-Level la S, but so far I think the best and easiest method for browser compatibility is the padding compensation method. First, set the padding-bottom of the column to a value that is large enough, and then set the margin-bottom of the column to a negative value that is offset by the positive value of the previous padding-bottom, the parent container settings exceed the hidden level, so that the height of the parent container is the height of the column in the parent container when no padding-bottom is set. When the height of any column in the parent container is increased, then, the height of the parent container is pushed to the highest column height in the parent container. Other columns shorter than the parent container will use their padding-bottom to compensate for the height difference. Because the background can be used in the space occupied by the padding, and the border also changes with the padding, a blind eye is successfully completed.

Code

First, let's look at the absence of high-level la S.

Effect:

Then we use a high-level layout:

The effect is as follows:

During the specific operation, the size of the padding-bottom value depends on the actual situation of your project. If you are not sure, it doesn't matter if you set it to a larger value.

Final code:

<! DOCTYPE html> 

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.