国产av日韩一区二区三区精品,成人性爱视频在线观看,国产,欧美,日韩,一区,www.成色av久久成人,2222eeee成人天堂

Home Web Front-end HTML Tutorial div css compatible with ie6 ie7 ie8 ie9 and FireFox Chrome method_html/css_WEB-ITnose

div css compatible with ie6 ie7 ie8 ie9 and FireFox Chrome method_html/css_WEB-ITnose

Jun 24, 2016 pm 12:31 PM

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

under the tag, then specify a class for the div, and then design the CSS like this:

#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
② 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:after { content:"."; display:block; height:0; clear:both; visibility: hidden; }

.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; }

#box p {margin-top: 20px; margin-bottom: 20px; text-align:center; }

<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.

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 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

under the tag, then specify a class for the div, and then design the CSS like this:

#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
② 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:after { content:"."; display:block; height:0; clear:both; visibility:hidden; }

.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; }

#box p {margin-top: 20px; margin-bottom: 20px; text-align:center; }

<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.

Statement of this Website
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

Hot AI Tools

Undress AI Tool

Undress AI Tool

Undress images for free

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

Hot Topics

PHP Tutorial
1502
276
Implementing Clickable Buttons Using the HTML button Element Implementing Clickable Buttons Using the HTML button Element Jul 07, 2025 am 02:31 AM

To use HTML button elements to achieve clickable buttons, you must first master its basic usage and common precautions. 1. Create buttons with tags and define behaviors through type attributes (such as button, submit, reset), which is submitted by default; 2. Add interactive functions through JavaScript, which can be written inline or bind event listeners through ID to improve maintenance; 3. Use CSS to customize styles, including background color, border, rounded corners and hover/active status effects to enhance user experience; 4. Pay attention to common problems: make sure that the disabled attribute is not enabled, JS events are correctly bound, layout occlusion, and use the help of developer tools to troubleshoot exceptions. Master this

Configuring Document Metadata Within the HTML head Element Configuring Document Metadata Within the HTML head Element Jul 09, 2025 am 02:30 AM

Metadata in HTMLhead is crucial for SEO, social sharing, and browser behavior. 1. Set the page title and description, use and keep it concise and unique; 2. Add OpenGraph and Twitter card information to optimize social sharing effects, pay attention to the image size and use debugging tools to test; 3. Define the character set and viewport settings to ensure multi-language support is adapted to the mobile terminal; 4. Optional tags such as author copyright, robots control and canonical prevent duplicate content should also be configured reasonably.

Best HTML tutorial for beginners in 2025 Best HTML tutorial for beginners in 2025 Jul 08, 2025 am 12:25 AM

TolearnHTMLin2025,chooseatutorialthatbalanceshands-onpracticewithmodernstandardsandintegratesCSSandJavaScriptbasics.1.Prioritizehands-onlearningwithstep-by-stepprojectslikebuildingapersonalprofileorbloglayout.2.EnsureitcoversmodernHTMLelementssuchas,

HTML for email templates tutorial HTML for email templates tutorial Jul 10, 2025 pm 02:01 PM

How to make HTML mail templates with good compatibility? First, you need to build a structure with tables to avoid using div flex or grid layout; secondly, all styles must be inlined and cannot rely on external CSS; then the picture should be added with alt description and use a public URL, and the buttons should be simulated with a table or td with background color; finally, you must test and adjust the details on multiple clients.

How to associate captions with images or media using the html figure and figcaption elements? How to associate captions with images or media using the html figure and figcaption elements? Jul 07, 2025 am 02:30 AM

Using HTML sums allows for intuitive and semantic clarity to add caption text to images or media. 1. Used to wrap independent media content, such as pictures, videos or code blocks; 2. It is placed as its explanatory text, and can be located above or below the media; 3. They not only improve the clarity of the page structure, but also enhance accessibility and SEO effect; 4. When using it, you should pay attention to avoid abuse, and apply to content that needs to be emphasized and accompanied by description, rather than ordinary decorative pictures; 5. The alt attribute that cannot be ignored, which is different from figcaption; 6. The figcaption is flexible and can be placed at the top or bottom of the figure as needed. Using these two tags correctly helps to build semantic and easy to understand web content.

How to handle forms submission in HTML without a server? How to handle forms submission in HTML without a server? Jul 09, 2025 am 01:14 AM

When there is no backend server, HTML form submission can still be processed through front-end technology or third-party services. Specific methods include: 1. Use JavaScript to intercept form submissions to achieve input verification and user feedback, but the data will not be persisted; 2. Use third-party serverless form services such as Formspree to collect data and provide email notification and redirection functions; 3. Use localStorage to store temporary client data, which is suitable for saving user preferences or managing single-page application status, but is not suitable for long-term storage of sensitive information.

What are the most commonly used global attributes in html? What are the most commonly used global attributes in html? Jul 10, 2025 am 10:58 AM

class, id, style, data-, and title are the most commonly used global attributes in HTML. class is used to specify one or more class names to facilitate style setting and JavaScript operations; id provides unique identifiers for elements, suitable for anchor jumps and JavaScript control; style allows for inline styles to be added, suitable for temporary debugging but not recommended for large-scale use; data-properties are used to store custom data, which is convenient for front-end and back-end interaction; title is used to add mouseover prompts, but its style and behavior are limited by the browser. Reasonable selection of these attributes can improve development efficiency and user experience.

Implementing Native Lazy Loading for Images in HTML Implementing Native Lazy Loading for Images in HTML Jul 12, 2025 am 12:48 AM

Native lazy loading is a built-in browser function that enables lazy loading of pictures by adding loading="lazy" attribute to the tag. 1. It does not require JavaScript or third-party libraries, and is used directly in HTML; 2. It is suitable for pictures that are not displayed on the first screen below the page, picture gallery scrolling add-ons and large picture resources; 3. It is not suitable for pictures with first screen or display:none; 4. When using it, a suitable placeholder should be set to avoid layout jitter; 5. It should optimize responsive image loading in combination with srcset and sizes attributes; 6. Compatibility issues need to be considered. Some old browsers do not support it. They can be used through feature detection and combined with JavaScript solutions.

See all articles