Home Web Front-end CSS Tutorial Common browser compatibility issues in html and css

Common browser compatibility issues in html and css

Nov 16, 2017 pm 05:01 PM
css html Browser

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;
Copy after login

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;}
Copy after login

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; //使浮动忽略
}
Copy after login

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
Copy after login

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

,

,

,
,

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

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.

Undress AI Tool

Undress AI Tool

Undress images for free

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 Article

Roblox: Bubble Gum Simulator Infinity - How To Get And Use Royal Keys
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Nordhold: Fusion System, Explained
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
Mandragora: Whispers Of The Witch Tree - How To Unlock The Grappling Hook
3 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

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

Java Tutorial
1665
14
PHP Tutorial
1269
29
C# Tutorial
1249
24
HTML vs. CSS and JavaScript: Comparing Web Technologies HTML vs. CSS and JavaScript: Comparing Web Technologies Apr 23, 2025 am 12:05 AM

HTML, CSS and JavaScript are the core technologies for building modern web pages: 1. HTML defines the web page structure, 2. CSS is responsible for the appearance of the web page, 3. JavaScript provides web page dynamics and interactivity, and they work together to create a website with a good user experience.

How to register an account on Ouyi Exchange Ouyi Exchange Registration Tutorial How to register an account on Ouyi Exchange Ouyi Exchange Registration Tutorial Apr 24, 2025 pm 02:06 PM

The steps to register an Ouyi account are as follows: 1. Prepare a valid email or mobile phone number and stabilize the network. 2. Visit Ouyi’s official website. 3. Enter the registration page. 4. Select email or mobile phone number to register and fill in the information. 5. Obtain and fill in the verification code. 6. Agree to the user agreement. 7. Complete registration and log in, carry out KYC and set up security measures.

Download the official website of Ouyi Exchange app for Apple mobile phone Download the official website of Ouyi Exchange app for Apple mobile phone Apr 28, 2025 pm 06:57 PM

The Ouyi Exchange app supports downloading of Apple mobile phones, visit the official website, click the "Apple Mobile" option, obtain and install it in the App Store, register or log in to conduct cryptocurrency trading.

Binance download link Binance download path Binance download link Binance download path Apr 24, 2025 pm 02:12 PM

To safely download the Binance APP, you need to go through the official channels: 1. Visit the Binance official website, 2. Find and click the APP download portal, 3. Choose to scan the QR code, app store, or directly download the APK file to download to ensure that the link and developer information are authentic, and enable two-factor verification to protect the security of the account.

Sesame Open Door Official Website Entrance Sesame Open Door Official Latest Entrance 2025 Sesame Open Door Official Website Entrance Sesame Open Door Official Latest Entrance 2025 Apr 28, 2025 pm 07:51 PM

Sesame Open Door is a platform that focuses on cryptocurrency trading. Users can obtain portals through official websites or social media to ensure that the authenticity of SSL certificates and website content is verified during access.

Ouyi official website entrance Ouyi official latest entrance 2025 Ouyi official website entrance Ouyi official latest entrance 2025 Apr 28, 2025 pm 07:48 PM

Choose a reliable trading platform such as OKEx to ensure access to the official entrance.

How to register an account on Sesame Open Exchange? Tutorial on Registration of Sesame Open Exchange How to register an account on Sesame Open Exchange? Tutorial on Registration of Sesame Open Exchange Apr 24, 2025 pm 02:00 PM

Registering a Sesame Door Account requires 7 steps: 1. Prepare a valid email or mobile phone number and a stable network; 2. Visit the official website; 3. Enter the registration page; 4. Select and fill in the registration method; 5. Obtain and fill in the verification code; 6. Agree to the user agreement; 7. Complete registration and log in, it is recommended to carry out KYC and set security measures.

Binance official website entrance Binance official latest entrance 2025 Binance official website entrance Binance official latest entrance 2025 Apr 28, 2025 pm 07:54 PM

Visit Binance official website and check HTTPS and green lock logos to avoid phishing websites, and official applications can also be accessed safely.

See all articles