The depressing 1px-IE6 is definitely a magic bug.

Source: Internet
Author: User

 

YesterdayBorder rounded cornerA bug was found.

This bug actually exists in IE 6 or earlier versions.

 

The cause is:

1. The outer element is located using position: relative, and the actual content width/height is odd;

2. The inner layer uses position: absolute to locate and uses bottom/Right to locate.

 

Let's take a closer look at the differences between the following two situations (This bug does not occur in other browsers to use browsers earlier than IE6.):

(1)

19px
38px
57px

Magic 1px

(2)

19px
38px

Magic 1px

 

This is usedCode:

Code
< Style Type = "Text/CSS" >
. Wrapper {
Position : Relative ;
Width : 201px ;
Line-height : 19px ;  
Background : #000 ;  
Color : # Fff ;
}
. OBJ {
Position : Absolute ;  
Right : 0px ;  
Bottom : 0px ;  
Border : 1px solid # f00 ;
}
</ Style >

(1)
< Div Class = "Wrapper" >
19px < BR > 38px < BR > 57px
< Div Class = "OBJ" > Magic 1px </ Div >
</ Div >
(2)
< Div Class = "Wrapper" >
19px < BR > 38px
< Div Class = "OBJ" > Magic 1px </ Div >
</ Div >

You may find that, in (2), the inner Div can locate the bottom of the parent element according to the expected bottom. The position of bottom: 1px is displayed in (1.

This is the so-called magic 1px.

The difference is that (1) the height of the parent element is 19*3 = 57px, and (2) the height of the parent element in (2) is 19*2 = 38px, the difference between an odd number and an even number.

 

Let's construct the following example:

(3)

Magic 1px

(4)

Magic 1px

 

Code:

Code
< Style Type = "Text/CSS" >
. OBJ {
Position : Absolute ;  
Right : 0px ;  
Bottom : 0px ;  
Border : 1px solid # f00 ;
}
. Wrapper1 {
Position : Relative ;
Width : 100px ;
Height : 100px ;
Background : #000 ;  
Color : # Fff ;
}
. Wrapper2 {
Position : Relative ;
Width : 101px ;
Height : 101px ;
Background : #000 ;  
Color : # Fff ;
}
</ Style >

(3)
< Div Class = "Wrapper1" >
< Div Class = "OBJ" > Magic 1px </ Div >
</ Div >
(4)
< Div Class = "Wrapper2" >
< Div Class = "OBJ" > Magic 1px </ Div >
</ Div >

 

As you can see clearly, bottom and right positioning in (4) both have similar problems, but not in (3. The difference between (3) and (4) lies in the parity difference between width and height.

That is to say, when the outer content height or width (tested padding has no effect on this) is an odd number, the absolute position of bottom and right will see a + 1px deviation.

 

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.