判断浏览器版本加载对应的样式表(文件)

1、HTML页:

 1 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 2 <html xmlns="http://www.w3.org/1999/xhtml">
 3 <head>
 4     <title></title>
 5     <script src="Scripts/jquery-1.7.1.min.js" type="text/javascript"></script>
 6     <!---如果是IE7---->
 7     <!--[if IE 7]>  
 8        <link href="Content/IE7.css" rel="stylesheet" type="text/css" />
 9    <![endif]-->
10 
11     <!---如果是IE8---->
12     <!--[if IE 8]>
13            <link href="Content/IE8.css" rel="stylesheet" type="text/css" />
14        <![endif]-->
15 
16     <!--[if lt IE 6]> IE6以及IE6以下版本可识别 <![endif]-->
17     <!--[if gte IE 6]> IE6以及IE6以上版本可识别 <![endif]-->
18 
19     <!---如果不是IE---->
20     <!--[if !IE]><!-->
21     <link rel="stylesheet" type="text/css" href="Content/gg.css" />
22     <!--<![endif]-->
23 </head>
24 <body>
25     <div class="main">
26     </div>
27     <input type="text" />
28 </body>
29 </html>

2、样式表:

(1)IE7.css

1 body {
2 }
3 .main
4 {
5     width:200px;
6     height:100px;
7     background-color:Red;
8 }

(2)IE8.css

1 body {
2 }
3 .main
4 {
5     width:200px;
6     height:100px;
7     background-color:Gray;
8 }

(3)非IE浏览器,other.css

1 body {
2 }
3 .main
4 {
5     width:200px;
6     height:100px;
7     background-color:Yellow;
8 }

3、效果:

(1)IE7

(2)IE8

(3)谷歌浏览器

(finish!)

转载于:https://www.cnblogs.com/dean-Wei/p/4153353.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值