Home > Web Front-end > CSS Tutorial > How Can I Apply CSS Hacks to Specifically Target Different Safari Versions?

How Can I Apply CSS Hacks to Specifically Target Different Safari Versions?

Patricia Arquette
Release: 2024-12-24 20:15:12
Original
137 people have browsed it

How Can I Apply CSS Hacks to Specifically Target Different Safari Versions?

Safari-Specific CSS Hack

While the provided code failed to differentiate Safari from Chrome, alternative CSS hacks are available that exclusively target Safari versions 6.1 and higher. Here's one such hack:

_::-webkit-full-page-media, _:future, :root .safari_only {
  color: #0000FF;
  background-color: #CCCCCC;
}
Copy after login

Version-Specific Safari Hacks

For Safari versions 10.1 and higher, use this hack:

/* Safari 10.1+ */
@media not all and (min-resolution: .001dpcm) {
  @media {
    .safari_only {
      color: #0000FF;
      background-color: #CCCCCC;
    }
  }
}
Copy after login

For Safari versions 6.1 to 10.0, use this hack:

/* Safari 6.1-10.0 (not 10.1) */
@media screen and (min-color-index: 0) and (-webkit-min-device-pixel-ratio: 0) {
  @media {
    .safari_only {
      color: #0000FF;
      background-color: #CCCCCC;
    }
  }
}
Copy after login

To apply these hacks, add a class named "safari_only" to the elements you want to style for Safari only.

The above is the detailed content of How Can I Apply CSS Hacks to Specifically Target Different Safari Versions?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
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
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template