


div css compatible with ie6 ie7 ie8 ie9 and FireFox Chrome method_html/css_WEB-ITnose
1. Vertical centering problem of div
vertical-align:middle; Increase the line spacing to the same height as the entire DIV line-height:200px; Then insert text and it will be vertically centered. The disadvantage is that the content must be controlled not to wrap.
2. The problem of doubling the margin
The margin set for a div set to float under IE will be doubled. This is a bug that exists in ie6. The solution is to add display:inline; to this div. For example:
<#div id="imfloat">
The corresponding css is
#imfloat{
float:left;
margin:5px;/*under IE, it is understood as 10px*/
display:inline;/*under IE, it is understood as 5px*/}
3. Double distance generated by floating IE
#box{ float:left; width:100px; margin:0 0 0 100px; //In this case, IE will generate a distance of 200px display:inline; //Ignore floats}
Let’s talk about the two elements block and inline in detail: The characteristic of the block element is that it always starts on a new line, and the height, width, line height, and margins can all be controlled ( Block element); The characteristic of Inline elements is that they are on the same line as other elements and cannot be controlled (inline elements);
#box{ display:block; //Can simulate inline elements as block elements display:inline; //Achieve the effect of arranging in the same row diplay:table;
4 Problems with IE and width and height
IE does not recognize the definition of min-, but in fact it puts it normally The width and height are treated as if there is min. This is a big problem. If you only use width and height, these two values will not change in a normal browser. If you only use min-width and min-height, the width and height are not set at all under IE.
For example, if you want to set a background image, this width is more important. To solve this problem, you can do this:
#box{ width: 80px; height: 35px;}html>body #box{ width: auto; height: auto; min-width: 80px; min-height: 35px;}
5. The minimum width of the page
min-width is a very convenient CSS command. It can specify that the element must be at least or not less than a certain width, thus ensuring that the layout is always correct. . But IE doesn't recognize this, and it actually treats width as the minimum width. In order to make this command also available on IE, you can put a
#container{ min-width : 600px; width:expression(document.body.clientWidth
The first min-width is normal; but the width in line 2 uses Javascript , which is only recognized by IE, which will also make your HTML document less formal. It actually implements the minimum width through Javascript judgment.
6. DIV floating IE text produces a 3-pixel bug
The object on the left is floating, and the right is positioned using the left margin of the outer patch. The text within the object on the right will be 3px away from the left. .
#box{ float:left; width:800px;}
#left{ float:left; width:50%;}
#right{ width:50%;}
*html #left{ margin-right:-3px; //This sentence is the key}
<div id="box">
<div id="left"></div>
<div id="right"></div>
</div>
7. IE hide-and-seek problem
When the div application is complex, there are Some links, DIVs, etc. are prone to hide-and-seek problems at this time.
Some content cannot be displayed. When the mouse selects this area, it is found that the content is indeed on the page.
Solution: Use line-height attribute for #layout or use fixed height and width for #layout. Keep the page structure as simple as possible.
8. Float div closure; clear float; adaptive height;
①For example:
<#div id="floatA" ><#div id= "floatB" ><#div id="NOTfloatC" >
The NOTfloatC here does not want to continue to translate, but wants to move down. (The attributes of floatA and floatB have been set to float:left;) This code has no problem in IE, but the problem lies in FF. The reason is that NOTfloatC is not a float label, and the float label must be closed. Add between There cannot be a nested relationship between divs at the same level, otherwise an exception will occur. And define the clear style as follows: .clear{ clear:both;}
② Do not set the height of the div as an external wrapper. In order to allow the height to automatically adapt, add it to the wrapper. Go to overflow:hidden; When a box containing float is included, the height automatic adaptation is invalid under IE. At this time, the layout private attribute of IE should be triggered (the evil IE!) You can use zoom:1; to achieve this. compatible. For example, a wrapper is defined as follows:
.colwrapper{ overflow:hidden; zoom:1; margin:5px auto;}
③For typesetting, the CSS description we use most is probably float :left. Sometimes we need to create a unified background behind the float div in column n, for example:
<div id="page">
<div id="left"> </div>
<div id=”center”></div>
<div id=”right”></div>
</div> We want to set the background of the page to blue so that the background color of all three columns is blue. However, we will find that as the left center right stretches downward, the page actually saves the height unchanged. The problem arises. , the reason is that page is not a float attribute, and our page cannot be set to float because it needs to be centered, so we should solve it like this
<div id="page">
<div id="bg ” style=”float:left;width:100%”><div id=”left”></div>
<div id=”center”></div>
<div id="right"></div>
</div>
</div>
Then embed a float left DIV with a width of 100% to solve the problem
④Universal float closure (very important!)
For the principle of clear float, please refer to [How To Clear Floats Without Structural Markup]. Add the following code to Global CSS and add the following to the div that needs to be closed. class="clearfix" is enough, it works repeatedly.
/* Clear Fix */
.clearfix { display:inline-block; }
/* Hide from IE Mac */
.clearfix {display:block;}
/* End hide from IE Mac */
/* end of clearfix */
Or set it like this:
.hackbox{ display:table; //Display the object as a block element-level table}
9. Height incompatibility
Height incompatibility means that when the height of the inner object changes, the height of the outer layer cannot be automatically adjusted, especially when the inner object uses margin or paddign.
Example:
#box {background-color:#eee; }
<div id="box">
<p>Content in p object</p>
</div>
Solution: Add 2 spaces above and below the P object The CSS code of the div object: .1{height:0px;overflow:hidden;} or add the border attribute to the DIV.
vertical-align:middle; Increase the line spacing to the same height as the entire DIV line-height:200px; Then insert text and it will be vertically centered. The disadvantage is that the content must be controlled not to wrap.
2. The problem of doubling the margin
The margin set for a div set to float under IE will be doubled. This is a bug that exists in ie6. The solution is to add display:inline; to this div. For example:
<#div id="imfloat">
The corresponding css is
#imfloat{
float:left;
margin:5px;/*under IE, it is understood as 10px*/
display:inline;/*under IE, it is understood as 5px*/}
3. Double distance generated by floating IE
#box{ float:left; width:100px; margin:0 0 0 100px; //In this case, IE will generate a distance of 200px display:inline; //Ignore floats}
Let’s talk about the two elements block and inline in detail: The characteristic of the block element is that it always starts on a new line, and the height, width, line height, and margins can all be controlled ( Block element); The characteristic of Inline element is that it is on the same line as other elements and cannot be controlled (inline element);
#box{ display:block; //Can simulate inline elements as block elements display:inline; //Achieve the effect of arranging in the same row diplay:table;
4 IE and width and height Problem
IE does not recognize the definition of min-, but in fact it treats normal width and height as if there is min. This is a big problem. If you only use width and height, these two values will not change in a normal browser. If you only use min-width and min-height, the width and height are not set at all under IE.
For example, if you want to set a background image, this width is more important. To solve this problem, you can do this:
#box{ width: 80px; height: 35px;}html>body #box{ width: auto; height: auto; min-width: 80px; min-height: 35px;}
5. The minimum width of the page
min-width is a very convenient CSS command. It can specify that the element must be at least or not less than a certain width, thus ensuring that the layout is always correct. . But IE doesn't recognize this, and it actually treats width as the minimum width. In order to make this command also available on IE, you can put a
#container{ min-width : 600px; width:expression(document.body.clientWidth
The first min-width is normal; but the width in line 2 uses Javascript , which is only recognized by IE, which will also make your HTML document less formal. It actually implements the minimum width through Javascript judgment.
6. DIV floating IE text produces a 3-pixel bug
The object on the left is floating, and the right is positioned using the left margin of the outer patch. The text within the object on the right will be 3px away from the left. .
#box{ float:left; width:800px;}
#left{ float:left; width:50%;}
#right{ width:50%;}
*html #left{ margin-right:-3px; //This sentence is the key}
<div id="box">
<div id="left"></div>
<div id="right"></div>
</div>
7. IE hide-and-seek problem
When the div application is complex, there are Some links, DIVs, etc. are prone to hide-and-seek problems at this time.
Some content cannot be displayed. When the mouse selects this area, it is found that the content is indeed on the page.
Solution: Use line-height attribute for #layout or use fixed height and width for #layout. Keep the page structure as simple as possible.
8. Float div closure; clear float; adaptive height;
①For example:
<#div id="floatA" ><#div id= ”floatB” ><#div id=”NOTfloatC” >
The NOTfloatC here does not want to continue to translate, but wants to go down. (The attributes of floatA and floatB have been set to float:left;) This code has no problem in IE, but the problem lies in FF. The reason is that NOTfloatC is not a float label, and the float label must be closed. Add between There cannot be a nested relationship between divs at the same level, otherwise an exception will occur. And define the clear style as follows: .clear{ clear:both;}
② Do not set the height of the div as an external wrapper. In order to allow the height to automatically adapt, add it to the wrapper. Go to overflow:hidden; When a box containing float is included, the height automatic adaptation is invalid under IE. At this time, the layout private attribute of IE should be triggered (the evil IE!) You can use zoom:1; to achieve this. compatible. For example, a wrapper is defined as follows:
.colwrapper{ overflow:hidden; zoom:1; margin:5px auto;}
③For typesetting, the CSS description we use most is probably float :left. Sometimes we need to create a unified background behind the float div in column n, for example:
<div id="page">
<div id="left"> </div>
<div id=”center”></div>
<div id=”right”></div>
</div> We want to set the background of the IC Trading Network page to blue so that the background color of all three columns is blue. However, we will find that as the left center right stretches downward, the page actually retains the same height. Here comes the problem. The reason is that page is not a float attribute, and our page cannot be set to float because it needs to be centered, so we should solve it like this
<div id=”page”>
<div id=”bg” style=”float:left;width:100%”>
<div id=”left”></ div>
<div id=”center”></div>
<div id=”right”></div>
</div> >
Then embed a float left DIV with a width of 100% to solve the problem
④Universal float closure (very important!)
For the principle of clear float, please refer to [How To Clear Floats Without Structural Markup], add the following code to Global CSS, and add class="clearfix" to the div that needs to be closed. It works every time.
/* Clear Fix */
.clearfix { display:inline-block; }
/* Hide from IE Mac */
.clearfix {display:block;}
/* End hide from IE Mac */
/* end of clearfix */
Or set it like this:
.hackbox{ display:table; //Display the object as a block element-level table}
9. Height incompatibility
Height incompatibility means that when the height of the inner object changes, the height of the outer layer cannot be automatically adjusted, especially when the inner object uses margin or paddign.
Example:
#box {background-color:#eee; }
<div id="box">
<p>Content in p object</p>
</div>
Solution: Add 2 spaces above and below the P object The CSS code of the div object: .1{height:0px;overflow:hidden;} or add the border attribute to the DIV.

The roles of HTML, CSS and JavaScript in web development are: 1. HTML is used to build web page structure; 2. CSS is used to beautify the appearance of web pages; 3. JavaScript is used to achieve dynamic interaction. Through tags, styles and scripts, these three together build the core functions of modern web pages.

Setting the lang attributes of a tag is a key step in optimizing web accessibility and SEO. 1) Set the lang attribute in the tag, such as. 2) In multilingual content, set lang attributes for different language parts, such as. 3) Use language codes that comply with ISO639-1 standards, such as "en", "fr", "zh", etc. Correctly setting the lang attribute can improve the accessibility of web pages and search engine rankings.

HTMLattributesareessentialforenhancingwebelements'functionalityandappearance.Theyaddinformationtodefinebehavior,appearance,andinteraction,makingwebsitesinteractive,responsive,andvisuallyappealing.Attributeslikesrc,href,class,type,anddisabledtransform

TocreatealistinHTML,useforunorderedlistsandfororderedlists:1)Forunorderedlists,wrapitemsinanduseforeachitem,renderingasabulletedlist.2)Fororderedlists,useandfornumberedlists,customizablewiththetypeattributefordifferentnumberingstyles.

HTML is used to build websites with clear structure. 1) Use tags such as, and define the website structure. 2) Examples show the structure of blogs and e-commerce websites. 3) Avoid common mistakes such as incorrect label nesting. 4) Optimize performance by reducing HTTP requests and using semantic tags.

ToinsertanimageintoanHTMLpage,usethetagwithsrcandaltattributes.1)UsealttextforaccessibilityandSEO.2)Implementsrcsetforresponsiveimages.3)Applylazyloadingwithloading="lazy"tooptimizeperformance.4)OptimizeimagesusingtoolslikeImageOptimtoreduc

The core purpose of HTML is to enable the browser to understand and display web content. 1. HTML defines the web page structure and content through tags, such as, to, etc. 2. HTML5 enhances multimedia support and introduces and tags. 3.HTML provides form elements to support user interaction. 4. Optimizing HTML code can improve web page performance, such as reducing HTTP requests and compressing HTML.

HTMLtagsareessentialforwebdevelopmentastheystructureandenhancewebpages.1)Theydefinelayout,semantics,andinteractivity.2)SemantictagsimproveaccessibilityandSEO.3)Properuseoftagscanoptimizeperformanceandensurecross-browsercompatibility.


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

Atom editor mac version download
The most popular open source editor

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Mac version
God-level code editing software (SublimeText3)

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment
