


Since the beginning of the Internet, the battle between browsers has never stopped. Of course, the hardest part is for web page developers. In order to meet user experience and usability standards, they have to work on multiple browsers for unified effects. I really hope that one day FF can dominate the world, although now IE still dominates the world. In particular, the CSS compatibility of Microsoft's latest IE7 browser has indeed added a heavy new burden to some web page producers.
In order to have the same display effect across browsers, we have to use CSS HACK. Of course, in this article we only talk about the most commonly used IE6 and FF, as well as the CSS HACK of IE7 that may become mainstream in the future. As for the versions below IE6 that are OP and SF, I will not explain them in detail here. Novices will definitely gain something from reading this article, and experts can just pass by and read it, haha!
Option 1
First, let’s take a look at the following CSS code:
background-color:orange;
*background-color:blue!important;
*background- color:red;
[Ctrl A Select all Note:If you need to introduce external Js, you need to refresh it before execution]
Let me briefly explain how each browser understands these three attributes: Under FF, the 2nd and 3rd attributes are not recognized. If the second attribute is just added with !important, FF will definitely recognize it, but because there is an * in front, it is not recognized (only IE7 recognizes it) . So what it reads is background-color:orange;
Under IE7, although IE7 recognizes the first, second, and third attributes, !important means priority, so what it reads is *background-color:blue !important;
Under IE6, the second attribute is not recognized, but the first and third attributes are recognized. However, because the third attribute overwrites the first attribute, IE6 finally reads *background-color: red.
Option 2
First take a look at the following CSS code:
background-color:orange;
*background-color:blue;
_background-color:red;
[Ctrl A 全选 注:如需引入外部Js需刷新才能执行]
下面我简单解释一下各浏览器怎样理解这三个属性:
在FF下,第2、3个属性FF不认识,所以它读的是background-color:orange;
在IE7下,第3个属性IE7不认识,所以它读第1、2个属性,又因为第2个属性覆盖了第1个属性,所以IE7最终读出的是第2个属性*background-color:blue;
在IE6下,这3个属性IE6都认识,所以3个属性都可以读取,又因为第3个属性覆盖掉前2个属性,所以IE6最终读取的是_background-color:red。
其中IE的读取属性一定要知道,这对初学者而言使用CSS HACK是非常至关重要的,浏览器读取属性是从上至下的,也就是说同样属性的设置最后一个读取到的才是在浏览器上显示的。此外在方案二种的“_”这是只有IE6才认识的,可见其大胃王的感觉。另外!important不同,它打破了从上至下的读取习惯,使用的是优先显示。而在上述两个方案中可以看出FF除了正规CSS书写和!important外其它都不认识,标准就是统一的。
在这里并不是怂恿大家鼓励使用CSS HACK,只是别看到其他人写的CSS代码中有这些HACK不知道是什么意思。毕竟用CSS HACK来解决浏览器间的兼容并不是长远方法,如果新版本浏览器的出现说不定会把你原来写的CSS HACK怎样,IE7就是个很好的例子。尽量达到零使用CSS HACK或者说少使用,因为好的布局结构是可以很好解决这些问题,这样的网站也大有人在。

在css中,可用list-style-type属性来去掉ul的圆点标记,语法为“ul{list-style-type:none}”;list-style-type属性可设置列表项标记的类型,当值为“none”可不定义标记,也可去除已有标记。

区别是:css是层叠样式表单,是将样式信息与网页内容分离的一种标记语言,主要用来设计网页的样式,还可以对网页各元素进行格式化;xml是可扩展标记语言,是一种数据存储语言,用于使用简单的标记描述数据,将文档分成许多部件并对这些部件加以标识。

在css中,可以利用cursor属性实现鼠标隐藏效果,该属性用于定义鼠标指针放在一个元素边界范围内时所用的光标形状,当属性值设置为none时,就可以实现鼠标隐藏效果,语法为“元素{cursor:none}”。

转换方法:1、给英文元素添加“text-transform: uppercase;”样式,可将所有的英文字母都变成大写;2、给英文元素添加“text-transform:capitalize;”样式,可将英文文本中每个单词的首字母变为大写。

在css中,可以利用“font-style”属性设置i元素不是斜体样式,该属性用于指定文本的字体样式,当属性值设置为“normal”时,会显示元素的标准字体样式,语法为“i元素{font-style:normal}”。

在css中,rtl是“right-to-left”的缩写,是从右往左的意思,指的是内联内容从右往左依次排布,是direction属性的一个属性值;该属性规定了文本的方向和书写方向,语法为“元素{direction:rtl}”。

在css3中,可以用“transform-origin”属性设置rotate的旋转中心点,该属性可更改转换元素的位置,第一个参数设置x轴的旋转位置,第二个参数设置y轴旋转位置,语法为“transform-origin:x轴位置 y轴位置”。


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

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

SAP NetWeaver Server Adapter for Eclipse
Integrate Eclipse with SAP NetWeaver application server.

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

mPDF
mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),