zoukankan      html  css  js  c++  java
  • 判断浏览器版本加载对应的样式表(文件)

    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!)

  • 相关阅读:
    expdp定时备份
    设计模式简介
    利用Python制作万年历
    Linux下Python的安装
    排序算法-直接插入排序
    排序算法-冒泡排序
    数据结构-循环顺序队列&链队列
    数据结构-栈&链栈
    数据结构-双向链表&双向循环链表
    数据结构-单链表&单循环链表
  • 原文地址:https://www.cnblogs.com/dean-Wei/p/4153353.html
Copyright © 2011-2022 走看看