css兼容浏览器问题

说到浏览器兼容问题,所有前端开发人员肯定都遇到过,这个问题需要面对,也必须得面对。
先说说IE浏览器版本吧,每个版本的IE浏览器有两种模式IE(Q)、IE(S),其中Q代表Quirks mode 怪异模式或混杂模式,这种模式很恶心。另一种是标准模式Standards mode,通常网上见到的很多代码和hack都是针对IE(S)来说的,一旦用户不小心切换到IE(Q),就可能造成意想不到的效果!

我们下面来看一下IE版本的不同hack吧,如下图:

这里写图片描述
enter image description here
看到网上很多资料写的“_”下划线是IE6特有的hack,不错,在IE6标准模式下面,是的。这样写没有问题。加入页面中IE6和IE7出现同样的问题的时候,我们可以用下划线,说不定IE6调好了,IE7也会跟着好了起来。

经过我实践发现“-”中划线的确是IE6特有的hack,你可以在你的页面中用中划线随便写针对IE6问题的代码,其他浏览器不会出现问题。

IE7特有的hack,一般认为是“*+”,星号和加号一起写。例如 :

aaa{height:25px;-height:30px;+height:31px;} / 普通高度是25像素,IE6是30像素,IE7是31像素 */
还有一种引进css的写法,也可以作为调整网站hack的办法,写法如下:

<!--[if IE 6]>
    <link href="ie/ie6.css" rel="stylesheet" type="text/css" />
<![endif]-->
<!--[if IE 9]>
    <link href="ie/ie9.css" rel="stylesheet" type="text/css" />
<![endif]-->
<!--[if IE 8]>
    <link href="ie/ie8.css" rel="stylesheet" type="text/css" />
<![endif]-->
<!--[if IE 7]>
    <link href="ie/ie7.css" rel="stylesheet" type="text/css" />
<![endif]-->
<!--[if IE]>
    <link href="ie/ie.css" rel="stylesheet" type="text/css" />
<![endif]-->
<!--[if lt IE 9]>
    <script src="html5_shrrr.js"></script>
<![endif]-->

其他IE的hack就不具体举例子了。

  .yy{
            background-color: #777777;/*所有识别*/
            background-color: #CD2626\9;/*ie6、7、8识别*/
            +background-color: #ddd;/*ie6、7识别*/
            _background-color: #ddd;/*ie6识别*/
        }

由于不同的浏览器对标签的默认样式不同,可以把所有元素都重新设置样式。

body,h1,h2,h3,h4,h5,h6,hr,p,blockquote,dl,dt,dd,ul,ol,li,pre,from,fieldset,legend,button,input,textarea,th,td{ margin:0; padding:0; }
body,button,input,select,textarea{  font: 12px/ 1.5, arial ,\aaa; }
h1,h2,h3,h4,h5,h6 {  font-size : 100%;} 
small{  font-size: 12px ;}
button,input,select,textarea {  font-size : 100%;} 
ul,ol{  list-style:none ;}
a{  text-decroation: none; }
a:hover{   text-decroation: underline;  }
sup{  vertical:text-top; }
sub{  vertical: text-bottom; }
fieldset,img{ border:0; }
table{ border-collapse: collapse; border-spacing:0 ;}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值