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.

Related Article

Cloud Intelligence Leading the Digital Future

Alibaba Cloud ACtivate Online Conference, Nov. 20th & 21st, 2019 (UTC+08)

Register Now >

Starter Package

SSD Cloud server and data transfer for only $2.50 a month

Get Started >

Alibaba Cloud Free Trial

Learn and experience the power of Alibaba Cloud with a free trial worth $300-1200 USD

Learn more >

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.