Is It Possible to Stylize Content Exclusively for Safari?
Problem:
You're struggling to find CSS that solely affects Safari, as previous methods also impact Chrome due to both browsers currently utilizing WebKit. Different alignments in Safari and Chrome make styling particularly challenging.
Solution:
/* Safari 7.1+ */ _::-webkit-full-page-media, _:future, :root .safari_only { color:#0000FF; /* Example text color */ background-color:#CCCCCC; /* Example background color */ }
Alternatively, for Safari 10.1 and above, use:
/* Safari 10.1+ */ @media not all and (min-resolution:.001dpcm) { @media { .safari_only { /* CSS styles */ } }}
or
/* Safari 10.1+ (alternate method) */ @media not all and (min-resolution:.001dpcm) { @supports (-webkit-appearance:none) { .safari_only { /* CSS styles */ } }}
For Safari 6.1 to 10.0, utilize:
/* 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 { /* CSS styles */ } }}
Additional hacks for specific Safari versions can be found in the provided response.
Usage:
<div>
Note:
Remember to always test these hacks on the provided live test page before implementing them on your website. Ensure that the test page works as intended, eliminating potential CSS conflicts.
The above is the detailed content of How Can I Apply CSS Styles Exclusively to Safari While Avoiding Conflicts with Other Browsers?. For more information, please follow other related articles on the PHP Chinese website!