V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX 提问指南
Eysa
V2EX  ›  问与答

CSS 怎么写 只有IE8能识别?

  •  
  •   Eysa · 2011-12-20 20:16:58 +08:00 · 5307 次点击
    这是一个创建于 4533 天前的主题,其中的信息可能已经有所发展或是发生改变。
    就IE8 最邪恶!
    15 条回复    1970-01-01 08:00:00 +08:00
    acgism
        1
    acgism  
       2011-12-20 20:20:43 +08:00
    <!--[if IE 8]>
    <link rel="stylesheet" href="" type="text/css" media="screen" />
    <![endif]-->
    <!--[if IE 6]>
    <link rel="stylesheet" href="" type="text/css" media="screen" />
    underone
        2
    underone  
       2011-12-20 20:27:07 +08:00
    这个。。如果不用if的话。。。
    后缀“\9”应该是让8以下的IE全部识别吧(还是9以下的)
    然后再用_和+做前缀分别识别6和7...8就出来了...
    当然这是笨办法...

    比如
    span.v2ex {
    font-size:12px;
    font-size:14px\9;
    +font-size:16px;
    _font-size:18px;
    }

    不知道是不是可以啊...记得不太清楚了...
    Eysa
        3
    Eysa  
    OP
       2011-12-20 20:27:38 +08:00
    这个。。。 能否在 CSS 里写个什么的。还要外链?
    Eysa
        4
    Eysa  
    OP
       2011-12-20 20:41:17 +08:00
    <fieldset>
    <legend align="right" style="">
    <h4 style=" font-size:30px;">这是一个标题</h4></legend>
    <div class="hack" style="margin-top: 20px; background-color:yellow;">
    万恶的IE8</div>
    <div style="margin-top: 20px; background-color:Red;">
    万恶的IE8</div>
    <p>
    <input type="submit" value="注册" />
    </p>
    </fieldset>



    求 hack
    acgism
        5
    acgism  
       2011-12-20 21:19:43 +08:00
    @Eysa 或者直接放弃IE 识别到IE内核的浏览器就直接跳转到这样的一个页面http://acgism.com/Just_say_no_to_IE/ (抽打,拖走。。。。
    Eysa
        6
    Eysa  
    OP
       2011-12-20 21:21:26 +08:00
    ....
    panlilu
        7
    panlilu  
       2011-12-20 21:25:24 +08:00
    @acgism 什么时候自己做个独立项目这么干一下~
    benzhe
        8
    benzhe  
       2011-12-20 21:33:48 +08:00
    http://www.jb51.net/css/24946.html

    但是这一条貌似IE9和Opera都支持:
    color:red\0; /* IE8支持 */
    bitsmix
        9
    bitsmix  
       2011-12-20 21:34:34 +08:00
    不过不建议用这种 css hack
    因为写出来的css都是invalid的
    Sivan
        10
    Sivan  
       2011-12-20 21:55:22 +08:00
    http://lightcss.com/best-way-to-different-browser-for-css/

    <!--[if lt IE 7 ]> <html class="ie6"> <![endif]-->
    <!--[if IE 7 ]> <html class="ie7"> <![endif]-->
    <!--[if IE 8 ]> <html class="ie8"> <![endif]-->
    <!--[if IE 9 ]> <html class="ie9"> <![endif]-->
    <!--[if (gt IE 9)|!(IE)]><!--> <html class=""> <!--<![endif]-->

    易维护,符合标准。
    kongruxi
        11
    kongruxi  
       2011-12-20 22:01:09 +08:00
    可以参考一下html5boilerplate

    http://html5boilerplate.com/
    thewei
        12
    thewei  
       2011-12-20 22:02:18 +08:00
    @Sivan 这种会容易维护,推荐。但如果是极个别而且只是小范围调整的样式可以用\0属性hack来指定只能IE8能识别这个样式,例如 #id { color: blue\0; }
    Sivan
        13
    Sivan  
       2011-12-20 22:04:59 +08:00
    @thewei 是啊。不过 CSS 代码不合标准的话有些前端心里会难受的。哈哈。
    thewei
        14
    thewei  
       2011-12-20 22:15:35 +08:00
    @Sivan 标准是可以给打破的,这两年学下来我觉得灵活用就行,呵呵。而且属性hack到最后可以也很容易查找出来。
    avatasia
        15
    avatasia  
       2011-12-20 22:34:44 +08:00
    死抱着标准不放的人,永世受
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   916 人在线   最高记录 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 22:03 · PVG 06:03 · LAX 15:03 · JFK 18:03
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.