Home >Web Front-end >CSS Tutorial >How Can I Apply CSS Rules Exclusively to a Div in Google Chrome?

How Can I Apply CSS Rules Exclusively to a Div in Google Chrome?

Susan Sarandon
Susan SarandonOriginal
2024-12-12 18:52:15564browse

How Can I Apply CSS Rules Exclusively to a Div in Google Chrome?

Applying CSS Rules to Chrome-Exclusive Elements

To apply specific CSS rules to a designated div solely in Google Chrome, consider the following strategies:

CSS Solutions (Source: jeffclayton.wordpress.com/2015/08/10/1279/)

  • Chrome, Safari, Microsoft Edge, and Firefox:

    @media screen and (-webkit-min-device-pixel-ratio:0) {
    div{top:10;} 
    }
  • Chrome 29 :

    @media screen and (-webkit-min-device-pixel-ratio:0)
    and (min-resolution:.001dpcm) {
      div{top:0;} 
    }
  • Chrome 22-28:

    @media screen and(-webkit-min-device-pixel-ratio:0) {
    .selector {-chrome-:only(; 
       property:value;
    );} 
    }

JavaScript Solution
Alternatively, you can use JavaScript to modify the div:

if (navigator.appVersion.indexOf("Chrome/") != -1) {
// modify button 
}

The above is the detailed content of How Can I Apply CSS Rules Exclusively to a Div in Google Chrome?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn