Difference in IE CSS

Source: Internet
Author: User

1. IE7, IE6 Div + CSS show different width definitions % L7 ^ + e # _ & F/B. C + A1 u

In terms of width definition, the width of IE7 is wider than that of IE6. This is the reason why the webpage may have overflow problems, fortunately, you can change the value or change the percentage. 2. ie7.0 fixed! Important bug. P. Z (F-W) S & Z

Previously due to ie6.0 pair! Important identifies bugs. The box model interpretation in Firefox and IE is inconsistent, resulting in a 2px difference. Most Web Standard designers use this bug to be compatible with ie6.0 and Firefox, that is, using: div {margin: 30px! Important; margin: 28px ;}. However, ie7.0 fixed this bug, so the problem emerged again. How can I be compatible with ie.7.0 and ie6.0 and Firefox?

7 I (["comment _ $ L4 t; a' K3 T, | 2 P3. box model change 3 H7 ^'s (O, b5 F7 |/G-d + P + G

In IE7, overflow behavior is modified to adapt to the css2.1 box model. 5 F, A-I (i8 u! I h't (x1

4. Some CSS filters in ie7.0 will no longer be available

Many potential resolution errors have been modified in % W $ K % S. Z8 N +} 8 H4 T # pie7, which may prevent filters from working properly in earlier ie versions. For example, * HTML filter, underline filter, And/*/comment filter. : S9 T4 C # X # X2 v

5. ie7.0 does not support many nonstandard CSS statements and has stricter requirements on JS syntax. 1 U6 L7 {4 S * x % I

Many JS pages normally displayed in IE6 cannot be displayed normally in IE7, and no error is prompted. Ie7.0 has stricter requirements on JS syntax, but this specification does not seem to be explained, and it does not clearly tell you how they are "standardized" and "Fan .; P5 I; A * Y3 S3 g

The above is my general understanding, and the following is the key: & R, y6 s 'm) r

. M + x) B, j) '/R3 @ 1 C4 F (Y-|

 

I. CSS hack

 

0 V3 V, _ 9 B % n! A; y -_! F8 |

& | $ P. P/+ L the following two methods can solve almost all hack.4 R: T $ P; B "C * C' ^ & R

'E "U5 S + E0 Z; K' H + M0 |

1 ,! Important

-Z "V # ^ 1 A5 l" G! {, B

7 h $ R2 K4 p! F + T7 K8 I with IE7! Important Support ,! The important method is only for the hack of IE6. (Note the writing method. Remember to declare the location in advance .), T! P5 K. J) U9 K

<Style>,]/R6 Z; B0 U4 H /~. D

# Wrapper. O. P' [: [(U/X: _ "Q & Z

{&~ /R' @-p-h +

Width: 100px! Important;/* IE7 + FF */

/J "[! B $ L1 A + ['x width: 80px;/* IE6 */

"K; Y4 U & D; V8 e} 5 R2 F. U5 K9 V (G "'

</Style> 〉! [9 E. S8 W5 O7 D9 t! T + E (u

& W3 t "~ 2 _-A3 ^ + M 2, IE6/ie77 for Firefox

# Y0 R (G # s # D7 K; {#@-T6 Y. h: S. Q's

* + HTML and * HTML are unique tags of IE, which are not supported by Firefox at the moment. * + HTML is also a unique tag of IE7.

+ Y3 F % Y: j9 f * S7 y # Z/R # x <style> 〉

"|-M8 Q7 H7 S: U # R # wrapper

$ D *} 'B (H1 y6 C0 [7 S3 M % @ 8 h {+ p1 A4 M # F1 _ ('0 |

# Wrapper {width: 120px;}/* Firefox */

6 F9 K. G4/6 o8 q) @ % K + T2 D3 t; F * html # wrapper {width: 80px;}/* IE6 fixed */

7 _ # E "G4 | 6 B! T "E1 D7 H: W * + html # wrapper {width: 60px;}/* IE7 fixed, pay attention to the Order */, J./6? 0 U) y' J

} (R4 I. s;] & S % Y # m

</Style> 〉

+ _ * O % S * z "S7 L1 L (M. B/B! R. C8 w * r)} 7 m

Note:

& [(E) S % u8 Q &} 0 f: Z3 o * + HTML for IE7 hack must ensure that the following statement is made on the top of HTML: 1 I. O2 l h: J! Uo

<〈! Doctype HTML public "-// W3C // dtd html 4.01 transitional // en" "http://www.w3.org/tr/html4/loose.dtd#〉8 'c3 R-E2 f r; H" G # B8 C

4x9 K5 M + S * n + L &?

2. Universal float closure (very important !)

5 O + W * D & D. | $ ~ 1 C $ G. _ 6 A1 T & Z1 L p *{

For details about the principle of clear float, refer to [How to clear floats without structural markup]

* S & E7 J "J" G # Z % R Add the following code to global CSS and add class = "Clearfix" to the DIV to be closed.

. Q9 @ 0 f y: D3 I4 @ <style> (S: @ * D. J-_ % G4 W9 S-

/* Clear fix */

+ O-F8 I * Y4 A + Z! F4 o # U. Clearfix: after [1 P2 ~) '-Y "W: Q3 J

{, | $ D/| & F5 Y5 A & R

Content: ".";: @ * O0 Y5 X) Z2 G1/

Display: block;

7 d 'b3 O3 P5 X! | 3x9 L) a height: 0;: H + M )? + O8 Q9 r$ |! ~; B

Clear: both;

8 m2 W $ H, u1 ^ "H visibility: hidden;" M7 o "Q T6/

}

2 W: G6 P. I '/-M. G "M. clearfix1}. R4 y9 A4 S: n8 J

{1 I $ f) Q * Z4 L) N

Display: inline-block;

'D4} (I3 '! F, j}

-U2 J2 H! ] 8 S $ R l6 A/* Hide from IE Mac */

: C (P #/5 R3 @ # H2 y /~ . Clearfix {display: block ;}

* O3 '& V4'; B/* end hide from IE Mac */

-^ * B) F M, W/K8 [// & Q/* end of Clearfix */"K4 X1 @ 'x. O) u2]

</Style> 〉

-X $} % H7 Z1 I/B + T7 o

4 Z3 L ('* A3 n/f * F 3. Other compatible techniques 6 y. l3 T # P) g * l0 T * E

H % '"A4 l //; P8 H

1. Setting padding for Div under FF will increase the width and height, but IE will not. (Available! Important solution)

0 B) C: T6 X: A & I

9 O9 L + P0/1 T3] $ Y % u'c 2, center problem 0 w # #~ 2 I! J %/8 A1

'P % Q, w A: l, X % L

1) vertical center. Set line-height to the same height of the current Div, and then use vertical-align: Middle. (Do not wrap the content) 2 N % u'a7 X8 I * B9 n

2). horizontal center. Margin: 0 auto; (of course not omnipotent)

} 0 T (e c $ G + O-u7 L 3. To add a style to the content of tag a, set display: block. (common in navigation labels)

! C) S3 V0 T3 P; _: C 4, FF and IE differences in Box understanding lead to a 2px difference, and there are also issues such as the DIV set to float doubling margin under IE.: P1 K4 Z) T %] 1 V (L

5. UL labels by default include list-style and padding under ff. it is best to declare it in advance to avoid unnecessary troubles. (common in navigation label and content list) 1 A2 H9 U6 v $ J0]

6. Do not set the height of the external wrapper Div. It is best to add overflow: hidden to achieve highly adaptive.

8 J "P4 h # Q6 H0 J8 K & G; a 7, about hand-shaped cursor. cursor: pointer. And hand only applies to ie.5 H ,~ 0 H1 C % K # A1 H6 F7

'Q * l; N/P1 G3 S2 y * o $ C

 

 

C2 F-A4 M1 Z8 g

1. Question about CSS Abbreviations:

 

$ F * X5 a % N: N "J/v6 v7_whether it is IE or FF, there is a small problem with CSS abbreviations, such as: Border: 0xp solid # FFF; there is no problem with the support of both browsers. However, if the magin of the four sides is different, this abbreviation cannot be used. The boundary interpretation error may occur either in IE or ff, this causes page deformation. $ N. M $ O. N4 W9 ^! C & E4 B) E5 R

Abbreviation: 6 N; j7 O7 [/V9 V0 H! L

Border-width: 0px 1px 2px 3px;

4 U) W1 l0 I, Y "W # oborder-style: solid;

! I: V. Q/l7 ;~ & I6 I3 [+ V8 custom fborder-color: # FFF;

Z & '"Q-G $ ~ % K2, magin padding, and other default values

9? 'Q -~ 2 K $ W ;[. p7 y * l ie has a default value of 0px for the magin padding of CSS, but FF is different. To maintain the uniformity of appearance, even if the padding is 0, you should write it, avoid FF misplacement in browsing.

# M %/8 e '^ 9 V. L "R" U "F & Y4 y7}-y; C V5 Q1 Z. N * R5 U .}

3. Center) S) E, B4 ~ -V Z

In IE, you can use body {text-align: center;} to align the center. In Firefox, it is always on the left. However, if float: Right is added, it cannot be in the middle when it reaches the right. In ff, set the Left and Right outer patches of the container to auto.

* F. B * ^ 7 W2 X! L! Emargin-Right: auto; 2 ~ % E # G. {$ ?. X/W0 {'B

Margin-left: auto;, P %] (X: H )'! M '?

For example: margin: 0 auto;

9 m % M. W "E ,? C; Y % Q. B) Friends of I2 B and bugs-browser remedies, bugs and solutions (Part 1) * M J (T & C8 @. B3 K /@

Http://realazy.org/blog/2006/07/29/working-with-buggy-browsers-1

'') S/L; N * q/I (E ====================================== ========================================

0 y/U % B3 V/G/J5 P0 ~ "Difference between ufirefox and IE in CSS style 1 CSS style 6 U. _ 4 I2 X1 for Firefox IE6 IE7 ?! O9 X, n

Most of them are used now! Important comes to hack. It can be displayed normally for IE6 and Firefox tests,

3 Z # L/K + Q * G3 W. C * D +? 4 D, but IE7! Important can be correctly explained, and the page will not be displayed as required! Find a needle

4 N: K-g/K -~ The good hack Method for IE7 is to use "* + html". Now you can use IE7 to browse it. It should be okay.

(X7/7 [^ + N0 W. Now you can write a CSS file like this: 4 N $/;] 5] + A5} "C

. N * D/V! P7 H + B, P % [! C #1 {color: #333;}/* Moz */: B! T % F-| 'P (J $ U & B

* Html #1 {color: #666 ;}/ * IE6 */8? 3 | # I 't7 D5 ^ 9 t

* + Html #1 {color: #999 ;}/ * IE7 */"B. @ 2 L; P' x *? % Z

The font color in Firefox is displayed as #333, the font color in IE6 is displayed as #666, And the font color in IE7 is displayed as #999.

7 A7 _ 7 z7 H * o /[! B2 V, g (P % C (? $ M * j

2. center problem in CSS layout

5 I "/5 V1 Z/A8 '3 M * w main style definition: 6 q + P0 M-[. T/e-W * T6 d

(K'e; U & Y "E; V8 E, hbody {text-align: center ;}

9 r'e0 D1 g, |-F9 U (y # center {margin-Right: auto; margin-left: auto ;}

9 I '}! @ * G8 C description:

"Q & R; {3 s/w $ v * n; S/x F & D/g first defines text-align: center in the parent element; this means that the content in the parent element is centered; for IE, this setting is enough. -^ 7 d # I6 G8 U $ I. p-D R0 v

However, it cannot be centered in Mozilla. The solution is to add "margin-Right: auto; margin-left: auto;" when the sub-element is defined ;"

1 I4 Q-o8 W8} 1 t it should be noted that, if you want to use this method to center the entire page, we recommend that you do not set it in a div, you can split multiple Div,

"~ * O '-C, @ * U2 L: K (~ You only need to define margin-Right: auto; margin-left: auto; in each split Div. % Z4], _! ^-@ 6 J) L

'T. J (K; L6 H3 box model different interpretations. 4 V8 Z: G; W4 W1 s, [O +/; c

: '"Q! H # B4 {4 P d * k $ W1 J # box {width: 600px; // For ie6.0-W/idth: 500px; // for FF + ie6.0}

5 u'n' (J + G % S2 H4 S & C; G # box {width: 600px! Important // for FF width: 600px; // for FF + ie6.0 width/**/: 500px; // For ie6.0 -}

% I-F5 X & Z, u (N6 {(W9 ^ $ J:] U3 y # W

4. Double distance of floating IE

; M3 B! X0 C + R! Y3 N: E) m

W % n8 D6 E9 A: |, H-[# F7 A # box {float: Left; width: 100px; margin: 0 0 0 100px; // In this case, ie will generate a 200px distance display: inline; // make floating ignore} 0 U, H * _ % v $ W/H )_

Here, let's take a closer look at the block and inline elements. The characteristics of the block elements are that they can always start on a new line, and the height, width, row height, and margins can be controlled (block elements ); the features of the inline element are as follows: On the same line as other elements ,... uncontrollable (embedded element );

# U1 {% T5 @ 4/|! /&]; I7 y

4 z7 x $ L4 c) e! P # box {display: block; // The embedded element can be simulated as the block element display: inline; // the result of the same row arrangement is dilay: Table; '['C % G, V9 E

: S % G2 |-H; x $ w'y2 V9 O ;~ 5 questions about IE and width and height

& Y: J3 R4 F +/1 A: _-H (v, J, O5 G-V3 Q * @ 0 J5 g/I; M3 Y. O

IE does not recognize the Min-definition, but in fact it treats normal width and height as Min conditions. In this case, the problem is big. If only the width and height are used, * a # V % G1 L-Z + P S9 t

In a normal browser, these two values will not change. If only Min-width and Min-height are used, the width and height under IE are not set at all. 4 L-R % P &? 6 Q: N2 L

For example, to set a background image, the width is important. To solve this problem, you can:

0 w. p'a5 H4 K # {# box {width: 80px; Height: 35px;} HTML> body # box {width: auto; Height: auto; Min-width: 80px; min-Height: 35px ;}

0 K1 B U $ t! J8 A; U6 ^! R. s) e $ s; B * X7 o ,_

6. The minimum page width is $ K. K4 M/I 'm2 v * a, X

2 '. G, L * D * I, d

Min-width is a very convenient CSS command, which can specify that the element is at least or less than a certain width, so as to ensure correct layout. But IE does not recognize this,

* J'x. z5 J6 I $ D, which uses width as the minimum width. To enable this command to be used on IE, you can place <div> under the <body> label and specify a class for div:

) E % Y, _ & W (x) w9'; O) D. Then CSS is designed as follows:

# D) Y4 ^ + B # e # K % T5 o' r! K:/# container {Min-width: 600px; width: expression (document. Body. clientwidth <600? "600px": "Auto ");}

4 D * '9 A8 Q5 Q6 N $} The first Min-width is normal, but the width of row 2nd uses JavaScript, which is recognized only by IE, this will also make your HTML documents less formal. It actually achieves the minimum width through javascript judgment. 'E7 S % E-x ^ 1 s '_! '

9 o-g/J8 M, L, Q: R (G & T7 i7 clear floating

$ C & C5 F9 M8 [. S -~ + V

2 G9 B1 i7 T3 u'e. hackbox {display: Table; // display the object as a table at the block element level} Or. hackbox {clear: Both;} 'd # C & C * K8 W! D

Or add: After (pseudo object) to set the content after the object, which is usually used with content. ie does not support this pseudo object, not supported by IE browsers ,) g3 x $ M: L * K % P % ';/

So it does not affect IE/win browsers. This is the most troublesome ...... # Box: After {content: "."; display: block; Height: 0; clear: Both; visibility: hidden ;}

1 T7 Q * G7 C3 L; F; G: S v/L4 | & K * E; j7 n )~ 8 n

8 DIV floating ie text produces 3 pixel bug

! T5 M/H9 E6? 4 f; ^ "f I/[9 E (Y + B

5 C/] $ Y8 '0 N5 A # I * t (the object on the left of N6 y floats, and the left margin of the outer patch is used to locate the object on the right, the text in the right object is 3 px away from the left.

7 |: G-Q % P # T) q % m'n; y "z' B & L7 u8 o! V4}/u7 U1 x

# Box {float: Left; width: 800px; }# left {float: Left; width: 50% ;}# right {width: 50% ;} * html # Left {margin-Right:-3px; // This sentence is critical}

8 B o8 S * L3 H5 g HTML code <Div id = "box"> <Div id = "Left"> </div> <Div id = "right"> </ div> </div> % F6 | 4 R-I3 | T, t

* N, k (r J5 _ 'e7 B0 d

9 attribute selector (this is not compatible, it is a bug for hiding CSS 'n! H u (H5 ^/} 2 t

: M6 F1 _ # R. [; '& R "B

P [ID] {} Div [ID] {}. U9 I: D8 A & Y * ^ %/9 {& T

This is hidden for versions earlier than ie6.0 and ie6.0. ff and opera function 7 [, C * _. e # K % A5 y/J2 R6 Z

There is a difference between the property selector and the Child selector. The range of the Child selector is reduced in the form, and the range of the property selector is relatively large, such as in P [ID, all P tags have IDs in the same style.

$ B 'U "G. | 3 _ 8 S5 Q7 ^: o n; V

* O, L1 ^-J0 ~ % J/h (J4 o10 ie hide-and-seek Problem

# T2 H1 A1 }! H x $ y! B! } 8'7 q u! P

When the DIV application is complicated, there are some links in each column. When the DIV application is complicated, it is prone to the "hide and seek" issue.

! A # G! I: f8', M % ~ 'N5 U1 {some content cannot be displayed. When you select this area, the content is indeed displayed on the page. # D/y! ^ % U & P5 R5 [% Z $ K9 P

Solution: Use the line-height attribute for # layout or use fixed height and width for # layout. The page structure should be as simple as possible.

'N4 Y2 J) [1] 9 _! V3 t)} 9 o) G # K2 {

11 highly unsuitable

/F. {8? * F6 C 'a7 K. ^: r1 F/E0 x *] 2 R & ^-P! O7 X5 d

The height mismatch means that the height of the outer layer cannot be automatically adjusted when the height of the inner layer object changes, especially when the inner layer object uses

) | (P6 I * @ 2 O; V2 vmargin or paddign.

/C9 D/C1 B $ m u. N0 [Example: 7 A * Q: A * y7 O) Q5 ^ 7g //

<Div id = "box">

3 J! F # E8 [(S1} <p> content in the p object </P>

# V4 w'u0 e $ o "R % x, K: j9 F </div> 4 Q4 ^ 5 N3 s! G % G

CSS: # box {background-color: # Eee;} 0 o T6 M-L $ x * B

# Box P {margin-top: 20px; margin-bottom: 20px; text-align: center;} $ p $ H5 ~ 2 T1 [& M/} 3 x % Z9 x

Solution: Add two empty Div objects to the upper and lower sides of the P object. CSS code:. 1 {Height: 0px; overflow: hidden;} or add the border attribute to the div.

8]:/0 @ $ N5 n! M/F1 e "T6 T, U6 n

Related Article

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.