开发者社区> 问答> 正文

什么是 Css Hack?ie6,7,8 的 hack 分别是什么?

什么是 Css Hack?ie6,7,8 的 hack 分别是什么?

展开
收起
茶什i 2019-11-18 15:34:37 1310 0
1 条回答
写回答
取消 提交回答
  • 针对不同的浏览器写不同的 CSS code 的过程,就是 CSS hack。

    示例如下:

    #test{
        width:300px;
        height:300px;
        background-color:blue;      /_firefox_/
        background-color:red\9;      /_all ie_/
        background-color:yellow;    /_ie8_/
        +background-color:pink;        /_ie7_/
        \_background-color:orange;       /_ie6_/   
    }
    
     :root #test { background-color:purple\9; }  /*ie9*/
    
    @media all and (min-width:0px)
    
         { #test {background-color:black;} }  /*opera*/
    
    @media screen and (-webkit-min-device-pixel-ratio:0)
    
    { #test {background-color:gray;} }       /*chrome and safari*/
    
    2019-11-18 15:35:26
    赞同 展开评论 打赏
问答分类:
问答标签:
问答地址:
问答排行榜
最热
最新

相关电子书

更多
零基础CSS入门教程 立即下载
低代码开发师(初级)实战教程 立即下载
阿里巴巴DevOps 最佳实践手册 立即下载