We will definitely use css in html development, but sometimes development is not as smooth as we thought. For example, common browser compatibility issues in html and css, then for this browser compatibility In this section, we will teach you how to solve the problem.
1. Centering problem
The content in the div is centered by IE by default, and left-aligned by FF by default. You can try adding code:
margin: 0 auto;
2. Height problem
For two divs arranged one above the other or nested, the height of the div above is set. If the actual content in the div is greater than the set height, the two divs will overlap in FF; but In IE, the div below will automatically make space for the div above. So in order to avoid overlapping layers, the height must be controlled appropriately, or you may simply not write the height and let it adjust automatically. A better method is height:100%. ;But when the first-level elements in this div are all floated, you need to add an empty div with a sunken bottom at the end of the div block and before closing. The corresponding CSS is:
float_bottom {clear:both;height:0px;font-size:0px;padding:0;margin:0;border:0;line-height:0px;overflow:hidden;}
3. clear: both;
If you don’t want to be affected by float, just write clear: both;
4. Double distance generated by IE floating margin
01#box { float:left; width:100px; margin:0 0 0 100px; //这种情况之下IE会产生200px的距离 display:inline; //使浮动忽略 }
5. Padding problem
After FF sets padding, div will increase height and width, but IE will not (* standard XHTML1.0 definition dtd seems to be consistent) height control Appropriate, or try to use height:100%; use padding to reduce the width. But according to actual experience, generally the padding of FF and IE will not be much different. The actual width of the div = width + padding, so write the full width and padding, width of the div. Define padding as the actual desired width.
6. Problems with padding and marign on the y-axis when divs are nested
The distance from the child div to the parent div on the y-axis in FF is parent padding + child marign
In IE, the distance between the child div on the y-axis and the parent div is the larger of the parent padding and the child margin
In FF, when the parent padding=0 and border=0 on the y-axis, the child div The distance to the parent div is 0, and the child margin acts outside the parent div
7. Foolish solution techniques for padding, margin, height, width
Note that this is a technique , not a method:
Write the standard header
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN” “http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd”> <html xmlns=” 高尽量用padding,慎用margin,height尽量补上100%,父级height有定值子级height不用100%,子级全为浮动时底部补个空clear:both的div宽尽量用margin,慎用padding,width算准实际要的减去padding
8. List class
1. The ul tag has a padding value by default in FF, but in In IE, only margin has a value
First define ul {margin:0;padding:0;}
2. Indentation problem of ul and ol lists When eliminating the indentation of ul, ol and other lists , the style should be written as: {list-style:none;margin:0px;padding:0px;}
9. Display class (display:block,inline)
1. Two elements, display:block and inline
display:block; //Inline elements can be simulated as block elements
display:inline; //Achieve the effect of being arranged in the same line
display:table; //for FF, simulate the effect of table
display:block block element, the characteristics of the element are:
Always start on a new line; Height, line height, and top and bottom margins are all controllable; the width defaults to 100% of its container, unless a width is set
,
,
The above is the detailed content of Common browser compatibility issues in html and css. For more information, please follow other related articles on the PHP Chinese website!

The fact that anchor positioning eschews HTML source order is so CSS-y because it's another separation of concerns between content and presentation.

Article discusses CSS margin property, specifically "margin: 40px 100px 120px 80px", its application, and effects on webpage layout.

The article discusses CSS border properties, focusing on customization, best practices, and responsiveness. Main argument: border-radius is most effective for responsive designs.

The article discusses CSS background properties, their uses in enhancing website design, and common mistakes to avoid. Key focus is on responsive design using background-size.

Article discusses CSS HSL colors, their use in web design, and advantages over RGB. Main focus is on enhancing design and accessibility through intuitive color manipulation.

The article discusses the use of comments in CSS, detailing single-line and multi-line comment syntaxes. It argues that comments enhance code readability, maintainability, and collaboration, but may impact website performance if not managed properly.

The article discusses CSS Selectors, their types, and usage for styling HTML elements. It compares ID and class selectors and addresses performance issues with complex selectors.

The article discusses CSS priority, focusing on inline styles having the highest specificity. It explains specificity levels, overriding methods, and debugging tools for managing CSS conflicts.


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

Dreamweaver Mac version
Visual web development tools

SublimeText3 English version
Recommended: Win version, supports code prompts!

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

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

Zend Studio 13.0.1
Powerful PHP integrated development environment
