首页 > 解决方案 > 仅对 chrome 应用 css

问题描述

我在我的网页中添加了一些 CSS 代码,我希望这个 CSS 代码只适用于 chrome。在 IE 上它已经在正确的位置。

@media only screen and (min-width:1280px) { 

    #x07ad3a0adb92619cc table tbody tr td img {
      max-width: 185% !important;
    }
    #xcfad3a0ad9619c9 table tbody tr td img {
       max-width: 155% !important; 
    }
    #x0fa3a0adb9219cf table tbody tr td img {
       max-width: 165% !important; 
    }
}

我已尝试以下媒体仅将 CSS 应用于 chrome

@media and (-webkit-min-device-pixel-ratio:0){
@media only screen and (min-width:1280px) { 

    #x07ad3a0adb92619cc table tbody tr td img {
      max-width: 185% !important;
    }
    #xcfad3a0ad9619c9 table tbody tr td img {
       max-width: 155% !important; 
    }
    #x0fa3a0adb9219cf table tbody tr td img {
       max-width: 165% !important; 
    }
}
}

但是网页图片的原始位置被折叠了。上面的代码不适用于 chrome。此外,这部分代码以红色显示。min-device-pixel-ratio:

在此处输入图像描述

我不明白我的代码有什么问题:-(

谁能帮我?

提前致谢!!

标签: htmlcsstwitter-bootstrap

解决方案


你应该试试这段代码

/* Chrome 29+ */
@media screen and (-webkit-min-device-pixel-ratio:0) and (min-resolution:.001dpcm) {
    // your code here
}

参考https://jeffclayton.wordpress.com/2015/08/10/1279/


推荐阅读