Home Web Front-end CSS Tutorial Differences in CSS style sheets between browsers Firefox and IE

Differences in CSS style sheets between browsers Firefox and IE

Dec 14, 2016 pm 03:37 PM

1 Css style for Firefox ie6 IE7

Nowadays most of them use !important to hack. For ie6 and firefox tests, it can be displayed normally, but ie7 can correctly interpret !important, which will cause the page not to be displayed as required! I found a good hack for IE7 which is to use "*+Html". Now browse it with IE7 and there should be no problem.

Now you can write a CSS like this:

#1 { color: #333; } /* Moz */
* html #1 { color: #666; } /* IE6 */
*+html #1 { color : #999; } /* IE7 */

Then the font color is displayed as #333 under firefox, #666 under IE6, and #999 under IE7.

2 Centering problem in css layout

The main style definition is as follows:

body {TEXT-ALIGN: center;}
#center { MARGIN-RIGHT: auto; MARGIN-LEFT: auto; }

Description:

First define TEXT-ALIGN: center in the parent element; this means that the content in the parent element is centered; this setting is enough for IE.

But it cannot be centered in mozilla. The solution is to add "MARGIN-RIGHT: auto;MARGIN-LEFT: auto;" when defining the child element. It should be noted that if you want to use this method to center the entire page, it is recommended not to use it. In a DIV, you can split multiple divs in sequence, just define MARGIN-RIGHT: auto;MARGIN-LEFT: auto; in each split div.

3 Different interpretations of the box model. important

                                                                                use using   using   using           through using ’ ’s ’ through out using ’ through ‐ ‐   ‐   ‐                                                  out out through out out out out out out out out Through Out Through outolece out Through together to  Th through ’ through ’ through-the-a-w-www ’ to ff ff

                     

#box{ float:left; width:100px; margin:0 0 0 100px; //In this case, IE will generate a distance of 200px display:inline; //Ignore the float}


Let’s talk about block in detail, There are two inline elements. 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 the Inline element is that it is on the same line as other elements. ...Uncontrollable (embedded elements);

#box{ display:block; //Can simulate inline elements as block elements display:inline; //Achieve the effect of being arranged in the same row diplay:table;

5 Problems with IE and width and height

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

6 Minimum width of the page

min-width is a very convenient CSS command. It can specify that the minimum width of the element cannot be less than a certain width, so as to ensure 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 work on IE, you can put a
under the tag, and then specify a class for the div:

Then the CSS is designed like this:

#container{

min-width : 600px;

width:e­ JavaScript, which is only recognized by IE, will also make your HTML document less formal. It actually implements the minimum width through Javascript judgment.

7 Clear Floating h.hackbox {

Display: Table;

// Display the object as a block of elements}}} or

.hackbox {

clear: both;

}

or add: afterr (Pseudo object), set the content that occurs after the object, usually used in conjunction with content. IE does not support this pseudo object and is not supported by Ie browsers, so it does not affect IE/WIN browsers. This is the most troublesome

......#box:after{
content: ".";

display: block;

height: 0;
clear: both;
visibility: hidden;
}

8 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 in the object on the right will have a 3px spacing 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
}
HTML code


/DIV>

9 attribute selector (this is not compatible, it is a bug in hiding css)

p[id]{}div[id]{}

p[id]{}div [id]{}

This is hidden for IE6.0 and versions below. FF and OPera function

There is still a difference between attribute selector and sub-selector. The scope of sub-selector is reduced in form. , the scope of the attribute selector is relatively large, such as p[id], all p tags with ids are of the same style.

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

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

Content in the p object



CSS:

#box {background-color:#eee } :0px;overflow:hidden;} Or add the border attribute to the DIV.


For more related articles, please pay attention to the PHP Chinese website (www.php.cn)!

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

How to remove Firefox Snap in Ubuntu Linux? How to remove Firefox Snap in Ubuntu Linux? Feb 21, 2024 pm 07:00 PM

To remove FirefoxSnap in Ubuntu Linux, you can follow these steps: Open a terminal and log in to your Ubuntu system as administrator. Run the following command to uninstall FirefoxSnap: sudosnapremovefirefox You will be prompted for your administrator password. Enter your password and press Enter to confirm. Wait for command execution to complete. Once completed, FirefoxSnap will be completely removed. Note that this will remove versions of Firefox installed via the Snap package manager. If you installed another version of Firefox through other means (such as the APT package manager), you will not be affected. Go through the above steps

Comparison and difference analysis between SpringBoot and SpringMVC Comparison and difference analysis between SpringBoot and SpringMVC Dec 29, 2023 am 11:02 AM

SpringBoot and SpringMVC are both commonly used frameworks in Java development, but there are some obvious differences between them. This article will explore the features and uses of these two frameworks and compare their differences. First, let's learn about SpringBoot. SpringBoot was developed by the Pivotal team to simplify the creation and deployment of applications based on the Spring framework. It provides a fast, lightweight way to build stand-alone, executable

In-depth comparison: Analysis of the differences between Dimensity 8200 and Snapdragon In-depth comparison: Analysis of the differences between Dimensity 8200 and Snapdragon Mar 22, 2024 pm 12:48 PM

In the era of mobile Internet, the performance of mobile phones has always been one of the focuses of users. As the leaders in the mobile phone chip market, MediaTek and Qualcomm have also attracted the attention of consumers for their chips. Recently, MediaTek launched the Dimensity 8200 chip, while Qualcomm has its representative Snapdragon series chips. So, what are the differences between these two chips? This article will conduct an in-depth comparative analysis between Dimensity 8200 and Snapdragon. First of all, from the perspective of process technology, Dimensity 8200 uses the latest 6nm process technology, while some of Qualcomm Snapdragon’s

Interpretation of differences between Oracle11g and Oracle12c versions Interpretation of differences between Oracle11g and Oracle12c versions Mar 07, 2024 pm 02:30 PM

Oracle Database has always been one of the leaders in enterprise-level database management systems, and its continuously updated and iterative versions have also attracted widespread attention. Among them, Oracle11g and Oracle12c versions are relatively representative versions and have many differences. This article will explain some important differences between Oracle11g and Oracle12c, and attach specific code examples to help readers gain a deeper understanding of the differences between the two versions. 1. Architecture differences Oracle1

How to create a slideshow layout page using HTML and CSS How to create a slideshow layout page using HTML and CSS Oct 16, 2023 am 09:07 AM

How to create a slide layout page using HTML and CSS Introduction: Slide layout is widely used in modern web design and is very attractive and interactive when displaying information or pictures. This article will introduce how to create a slide layout page using HTML and CSS, and provide specific code examples. 1. HTML layout structure First, we need to create an HTML layout structure, including a slide container and multiple slide items. The code looks like this: <!DOCTYPEhtml&

Can mozilla firefox be uninstalled? Can mozilla firefox be uninstalled? Mar 15, 2023 pm 04:40 PM

Mozilla Firefox can be uninstalled; Firefox is a third-party browser and can be uninstalled if it is not needed. Uninstallation method: 1. In the Start menu, click "Windwos System" - "Control Panel"; 2. In the "Control Panel" interface, click "Programs and Features"; 3. In the new interface, find and double-click Firefox Browser icon; 4. In the uninstall pop-up window, click "Next"; 5. Click "Uninstall".

Git or version control? Key Differences in PHP Project Management Git or version control? Key Differences in PHP Project Management Mar 10, 2024 pm 01:04 PM

Version Control: Basic version control is a software development practice that allows teams to track changes in the code base. It provides a central repository containing all historical versions of project files. This enables developers to easily rollback bugs, view differences between versions, and coordinate concurrent changes to the code base. Git: Distributed Version Control System Git is a distributed version control system (DVCS), which means that each developer's computer has a complete copy of the entire code base. This eliminates dependence on a central server and increases team flexibility and collaboration. Git allows developers to create and manage branches, track the history of a code base, and share changes with other developers. Git vs Version Control: Key Differences Distributed vs Set

How to use:nth-child(-n+5) pseudo-class selector to select the CSS style of child elements whose position is less than or equal to 5 How to use:nth-child(-n+5) pseudo-class selector to select the CSS style of child elements whose position is less than or equal to 5 Nov 20, 2023 am 11:52 AM

How to use:nth-child(-n+5) pseudo-class selector to select the CSS style of child elements whose position is less than or equal to 5. In CSS, the pseudo-class selector is a powerful tool that can be selected through a specific selection method. Certain elements in an HTML document. Among them, :nth-child() is a commonly used pseudo-class selector that can select child elements at specific positions. :nth-child(n) can match the nth child element in HTML, and :nth-child(-n) can match

See all articles