Home > Web Front-end > CSS Tutorial > How Can I Specifically Target Safari with CSS?

How Can I Specifically Target Safari with CSS?

Susan Sarandon
Release: 2024-12-26 16:28:09
Original
601 people have browsed it

How Can I Specifically Target Safari with CSS?

Isolating Styles to Safari

While isolating CSS to Safari might seem possible, most methods also apply to Chrome due to their shared WebKit foundation.

Effective and Specific Safari Hacks

To exclusively target Safari, consider these CSS hacks:

Safari 7.1 :

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

Safari 10.1 :

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

Safari 6.1-10.0:

@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

Usage:

Apply these CSS rules to a class named "safari_only" to target only Safari browsers. For example:

<div>
Copy after login

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

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