Home >Web Front-end >HTML Tutorial >(Experience) DIV CSS solves IE6, IE7, IE8, FF compatibility issues_html/css_WEB-ITnose
(Experience) DIV CSS solves IE6, IE7, IE8, FF compatibility issues
Let me talk about it. I have been working on DIV CSS for almost a year, and I have accumulated a lot of compatibility solutions. To solve the problem, I will only talk about the current mainstream ones here, (IE6, IE7, IE8, FF) and have not studied the others
1. Compatibility issues under ie8, this is best dealt with, just convert it to ie7 compatibility. . Add the following code to the header, and as long as it is compatible under IE7, it will also be compatible under IE8
2. Float floating causes double margin problem under IE6. This is the most common and best to deal with, !important solves it, such as
margin-left:10px !important;/*IE7,IE8,FF The bottom is 10PX*/;
margin-left:5px;/*The attribute written under IE6 is 5PX, but what is displayed is 10px
3. Clear the block display, this can solve the problem caused by floating Blocks, after forming blocks, when the DIV background is filled with color or picture, the background will be disconnected or a small block will appear. This kind of compatibility does not appear too often. I have only encountered it twice so far. The method is to write a display: block or other attributes in the CSS where the compatible DIV appears. I don’t know what it means in Chinese. I am English Poor, but it can achieve the desired effect, 6 e" Z e% |8 G# |
4. Many friends will see it when DIV CSS. It works fine in several IE browsers, but in FF Something went wrong. Using !important will make IE7 incompatible. It's a headache. I'm wondering if there is any way to operate it only under FF. I have used this method and it seems to be unsatisfactory. It is in the properties. Add symbols in front, such as: *, &, ¥, #, @, ?, . The attributes with symbols are only recognized by IE browsers, but not by FF. The method is as follows (note the difference between signed attributes and unsigned attributes. Order)
height:100px;/*Display 100 height under FF*/
height:120px;/*Display 120 height under IE678*/
5. Sometimes, in the layout At that time, I found that a DIV was floating. The next DIV was supposed to be displayed below, but it ended up above. This situation usually occurs below FF. The solution is to clear the floating and set it after setting. Add a DIV below the floating DIV, and write clear:both; in the CSS as follows
6. Then there is the centering problem. This problem occurs a lot for novices. The main reason is that the box model I don’t understand it well enough and haven’t memorized the box model. If I find that your page has no center, I know now that there are several reasons: 1. One is that there is no box, which is the big DIV after the BODY that holds all the DIVs. , you didn’t write it. 2. You did, but the width did not use absolute width: instead, it used a relative width. If you want to use it, you must use absolute width. -
7. Extension: If I want to. When designing, three different effects appear under IE6, IE7, and FF. For example, the background is red under IE6, blue under IE7, and green under FF. Here, I have tried it myself, and it works, using compatible methods (pay attention to the order, You can understand it better). 7 L& t- o7 k- a1 I
background:red;/*red displayed in FF*/
background:blue !important;/*blue displayed below IE7*/
background:green;/*Green displayed below IE6*/
Here, I want to say that although compatibility brings you a lot of depression and makes people upset, at the same time, when you do long After that, you will find that compatibility can sometimes satisfy you with many difficult-to-achieve effects. Just like the last one, if you want to achieve that effect without using compatibility methods, then you can use JS. For JS, you also have to think about FF and FF. The difference under IE, of course, is that I don’t know the compatibility of JS. I haven’t studied it. For the future, let’s learn CSS DIV first.
Do more, practice, and always keep the box model in your mind. Only then will you become proficient and able to use it freely. Only then will you naturally know where there are compatibility issues when doing it. Just do it before testing. Troubleshoot the most common compatibility issues.