Turn, dynamically generated highly adaptive

Source: Internet
Author: User

In IE, height self-adaptation is very easy, but in FF, if the DIV layer contains layers rather than directly filling the content, it will not automatically adapt to the height, this is often used when we set the background layer. The following is an example:

<Div id = "Container">
<Div id = "Main"/> </div>
<Div id = "sidebar"/> </div>
</Div>

As the outermost layer, container can be adaptive in IE, but only the main and sidebar layers can be used in ff. After a long time, I also asked many friends and finally found the answer from the Internet, simple:

Just define # container {
Display: Table}. The principle is the same as the previous table layout.

But this problem seems to cause a float layer error... If there is a better solution

You can leave a message.

Today, we have created another solution.

<Div id = "Container">
<Div id = "Main"/> </div>
<Div id = "sidebar"/> </div>
</Div>

The above sectionCode. Let's set the container height to 100%.
Height of main and sidebar: 100%.

In this wayFirefoxThe test passed in IE, which is better than the display: Table; method. Display: Table; may cause some layout errors.

We recommend that you use this height: 100%;

The general principle is that when the height of the Child-level Div increases, the height of the parent-level Div cannot be changed because the height of the parent-level div is not set. Therefore, we set the parent-level Div

The DIV height is 100%, but an error occurs if the height of the sub-Div is not set. Therefore, we specify the parent-level Div and sub-level Div as 100% at the same time.

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.