CSS hack for safari 5

时间:2013-04-11 02:37:10

标签: css css3 safari cross-browser css-hack

我正在开发一个网页,当我测试交叉浏览测试时,我得到的CSS样式与我的谷歌浏览器和我的Safari 5冲突。

我所有浏览器的代码(firefox,chrome,opera)

.flex-direction-nav-featured a{
       margin-top: 4%;
   } 

我试试这个,但它不会工作

/* for safari only (wont work)*/
::root .flex-direction-nav-featured a{
    margin-top: 5%;
}
/* for safari only (but works with chrome also)*/
@media screen and (-webkit-min-device-pixel-ratio:0) {
      /* works with sfari and chrome */
   .flex-direction-nav-featured a{
       margin-top: 5%;
   } 

}

是否存在仅针对Safari 5的CSS黑客攻击?我尝试过很多东西,但都没有用。

2 个答案:

答案 0 :(得分:13)

您可能想尝试通过伪类阻止chrome:

@media screen and (-webkit-min-device-pixel-ratio:0) { 
    /* Safari and Chrome */
    .flex-direction-nav-featured a{
        margin-top: 4%;
    } 

    /* Safari only override */
    ::i-block-chrome,.flex-direction-nav-featured a{
        margin-top: 5%;
    } 
}

答案 1 :(得分:2)

@media screen and (-webkit-min-device-pixel-ratio:0) { 
    /* Safari only override */
    ::i-block-chrome,.flex-direction-nav-featured a {
        margin-top: 5%;
    } 
}