If the width of the parent element of IE7 is adaptive and floating, the width of the child element cannot be set proportionally.

Source: Internet
Author: User

I haven't cut the graph for a long time. Yesterday I encountered an old browser compatibility problem. In IE7, after the parent element is set to float, its width is adaptive, if the width of the child element is not determined, the minimum width is displayed, that is, the width of the text.

Other normal browsers are shown as follows:

IE7 displays the following results:

Solution:

1. Add a fixed width to the parent element;

If method 1 violates the desired effect, it can only be processed using JS, that is, obtain the UL width of the same level node of H4, and then assign it to h4.

As follows:

<SCRIPT>
Window. onload = function (){
If (navigator. appname = "Microsoft Internet Explorer" & navigator. appversion. split (";") [1]. replace (/[]/g, "") = "msie7.0 "){
For (VAR I = 0; I <3; I ++ ){
Document. getelementbyid ('H _ '+ I). style. width = Document. getelementbyid ('U _' + I). offsetwidth + 'px ';
}
}
}
</SCRIPT>

First Judge IE7, and then run this code for IE7. You can also use JQ to achieve the same principle.

If the width of the parent element of IE7 is adaptive and floating, the width of the child element cannot be set proportionally.

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.