Home  >  Article  >  Web Front-end  >  DIV CSS solves IE6, IE7, IE8, FF compatibility issues_html/css_WEB-ITnose

DIV CSS solves IE6, IE7, IE8, FF compatibility issues_html/css_WEB-ITnose

WBOY
WBOYOriginal
2016-06-24 12:31:06953browse

1. Compatibility issues under ie8, this is best dealt with, just convert it to ie7 compatibility. Add the following code to the head, 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 solution, such as

margin-left:10px! important;/*Under IE7, IE8, FF it is 10PX*/;

margin-left:5px;/*The attribute written under IE6 is 5PX, but it is displayed as 10px

3. Clear the block display. This can solve the block caused by floating. After the block is formed, 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, but it is fine in several IE browsers. But something went wrong in FF. Using !important will make IE7 incompatible, which is a headache. I was wondering if there is any way to operate it only in FF. I have used this method, and it seems to be unsatisfactory. That is to add symbols in front of the attributes, such as: *, &, ¥, #, @, ?,. The attributes with symbols are only recognized by IE browsers, but not by FF. The method is as follows (note the attributes with symbols and attributes without symbols) The order of the attributes)

height:100px;/*The height of 100 is displayed under FF*/

height:120px;/*The height of 120 is displayed under IE678*/

5. Sometimes, during layout, it is found that a DIV is floating, and the next DIV is supposed to be displayed below, but ends up above it. This situation usually occurs under FF, and it can be solved. The way is to clear the float, add a DIV below the DIV that has been set to float, and write clear:both; in the CSS as follows

6. Then there is centering Problem, this problem occurs a lot for novices. The main reason is that they don’t understand the box model well and don’t memorize the box model. If you find that your page does not have a game, I now know that there are several reasons: 1. One is that there is no box. , which is the big DIV after BODY that holds all the DIVs together. You didn't write it. 2. You did, but the width didn't use absolute width: instead, it used a relative width. In the middle of the game, absolute width must be used. . -

7. Extension: If I want to achieve three different effects under IE6, IE7, and FF when designing, such as red background under IE6, blue under IE7 and green under FF, here, I have tried it myself, and it works, using a compatible method (pay attention to the order, you can understand it better) 7 L& t- o7 k- a1 I

background:red;/*The red color shown in FF*/<.>

background:blue !important;/*The blue color shown below IE7*/

background:green;/*The green color shown below IE6*/

Here, I I want to say that although compatibility brings you a lot of depression and upsets, at the same time, after you do it too much, you will find that compatibility can sometimes satisfy you with many difficult-to-achieve effects, just like the last one. To achieve that kind of effect, you don’t need to use compatibility methods, then you can use JS. You also have to think about the differences between FF and IE for JS. Of course, I don’t know how to use JS compatibility. 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.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn