日期:2014-05-17  浏览次数:20583 次

网页开发 浏览器间差异

1 、处理的问题是ie6,7无法识别新标签的问题
使用js解决,引入与下js,就可以识别了。

<!--[if lte IE 8]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
2 、html5的新标签无法使用设置css背景

刚开始试的时候,还以为哪出问题了,刚好其中的nav被clearfix修复了,才发现原来是display:block;的问题。
在你的reset.css或其它地方加入相关css解决:

header,nav,article,section,aside,footer{ display:block;}

?

一、通用区分方式:
IE都能识别*,标准浏览器(如FF)不能识别*;
IE6能识别*,但不能识别 !important;
IE7能识别*,也能识别 !important;
IE8能识别\0,不能识别*,+,_,*加!important;
FF不能识别*,但能识别 !important;
例如style=”*width:10px!important; width:20px;”,其在IE6下宽度为10px,在IE7下宽度时20px

其中还有如下三种写法:

第一种

width:100px; /* FireFox及其他浏览器 */
width:200px\0; /* IE8能识别\0*/
*width:300px!important; /* ,IE7 既能能识别*号,也能识别important */
*width:400px; /* IE6也能识别*号 */
/*提示:请注意顺序 */


第二种

width:100px; /* FireFox及其他浏览器 */
width:200px\0; /* IE8能识别\0*/
*width:300px; /* IE7也能识别*号 */
_width:400px; /* IE6能识别下划线*/
/*提示:请注意顺序 */


第三种

width:100px; /* FireFox及其他浏览器 */
width:200px\0; /* IE8能识别\0*/
+width:300px; /* +只识别IE7 */
_width:400px; /* IE6能识别下划线*/
/*提示:请注意顺序 */


二、不常见的HACK(OP表示Opera,SA表示Safari),其中第3条比较实用
.color1{ color:#F00; color/*\**/:#00F /*\**/}/*IE6,IE7,IE8,FF,OP,SA识别*/
.color2{ color:#F00; color /*\**/:#00F /*\9**/}/*IE7,IE8,FF,OP,SA识别*/
.color3{ color:#F00; color/*\**/:#00F \9}/*IE6,IE7,IE8识别*/
.color4{ color:#F00; color /*\**/:#00F\9}/*IE7,IE8识别*//*“color”和“/*\**/”之间有个空格*/


三、各种浏览器独立支持的hack
width:100px\0;/* 支持IE8 */
_width:100px; /* 支持IE6 */
[width:100px; /* 支持IE6,7 */
+width:100px; /* 支持IE6,7 */
*width:100px; /* 支持IE6,7 */
*width:100px!important; /* 支持IE6,7, */
*+width:100px; /* 支持IE6,7, */
*+width:100px!important;/* 支持IE6,7, */
width:100px\9; /* 支持IE6,7,8 */
width:100px!important; /* 支持IE6,7,8,FF */
w\idth:100px; /*IE5.x不支持 IE6、IE7、IE8、FF支持 */


四、IE特有的条件注释功能
1.仅IE可见的写法

<!--[if IE]>此处内容只有IE可见<![endif]–>


2.仅IE6可见的写法

<!–[if IE 6.0]>此处内容只有IE6.0可见<![endif]–>


3.仅IE7可见的写法

<!–[if IE 7.0]>此处内容只有IE7.0可见<![endif]–>


4.版本区间可显示写法

<!--[if lt IE 6]> IE6以及IE6以下版本可识别 <![endif]-->
<!--[if gte IE 6]> IE6以及IE6以上版本可识别 <![endif]-->
<!--[if lt IE 7]> IE7以及IE7以下版本可识别 <![endif]-->
<!--[if gte IE 7]> IE7以及IE7以上版本可识别 <![endif]-->


5.非IE可见的写法(注意:此条不符合WEB标准,但的确实用)

<!--[if !IE]>此处内容只非IE可见<![endif]-->