CSS 兼容性解决方案

来源:互联网 发布:mysql数据备份方案 编辑:程序博客网 时间:2024/05/22 06:18

1、Div的垂直居中的问题

vertical-align:middle; 将行距增加到和整个DIV一样高line-height:200px; 然后插入文字,就垂直居中了。缺点是要控制内容不要换行

2、IE6下图片有空隙产生

解决这个BUG的方法也有很多,可以是改变html的排版,或者设置imgdisplay:block或者设置vertical-align属性为vertical-align:top  bottom  middle  text-bottom都可以解决.

3、IE6、IE7、Firefox之间 的兼容写法

    1):

IE都能识别*;标准浏览器(Firefox)不能识别*

IE6能识别*,但不能识别!important,

IE7能识别*,也能识别!important;

Firefox不能识别*,但能识别!important;

根据上述表达,同一类/ID下的CSS hack可写为:

.searchInput {

background-color:#333;/*三者皆可*/

*background-color:#666 !important; /*IE7*/

*background-color:#999; /*IE6IE6以下*/

}

2):

IE6可识别“_”,而IE7Firefox皆不能识别,所以当只针对IE6IE7Firefox之间的区别时,可这样书写:

.searchInput {

background-color:#444;/*通用*/

_background-color:#555;/*IE6可识别*/

}

3):

*+html*htmlIE特有的标签, Firefox 暂不支持。

.searchInput {background-color:#333;}

*html .searchInput {background-color:#666;}/*IE6*/

*+html .searchInput {background-color:#555;}/*IE7*/