Skip to content

Instantly share code, notes, and snippets.

@jbutko
Created September 26, 2013 18:43
Show Gist options
  • Save jbutko/6718701 to your computer and use it in GitHub Desktop.
Save jbutko/6718701 to your computer and use it in GitHub Desktop.
CSS, Safari: Target only Safari browser
@media screen and (-webkit-min-device-pixel-ratio:0) {
/* Safari and Chrome */
.flex-direction-nav-featured a{
margin-top: 4%;
}
/* Safari only override */
::i-block-chrome,.flex-direction-nav-featured a{
margin-top: 5%;
}
}
@onenazmul
Copy link

It worked, thanks a lot @ntnbst

@yogesh-xseed
Copy link

yogesh-xseed commented Nov 3, 2020

@media screen and (-webkit-min-device-pixel-ratio: 0) { _::-webkit-full-page-media, _:future, :root , .some-class { top:just save 0; } }

@Valeka thank you so much you just saved my day.

@sanket4real
Copy link

Thanks @ntnbst, it worked

@xoriant-vikas
Copy link

@media not all and (min-resolution:.001dpcm)
{ @supports (-webkit-appearance:none) {

    .safari_only { 

        color:#0000FF;
        background-color:#CCCCCC; 

    }
}}

although its working perfectly but have sass lint error.

Include leading zeros on numbers for @media not all and (min-resolution:.001dpcm)

Vendor prefixes should not be used for @supports (-webkit-appearance:none)

@Chelny
Copy link

Chelny commented Mar 21, 2021

Thanks @ntnbst!

@Muhammad-Naiem
Copy link

need just ios chorme browser all media

@nguyen422
Copy link

@ntnbst works for me too ;) Thanks so much!!

@ShiBa-Shin
Copy link

@ntnbst Works like a charm. Thanks for shared this.

@Mil00Z
Copy link

Mil00Z commented Oct 4, 2021

@ntnbst
OMG , i don't really understand it works but thank you very much !!!! (if you have some explanations, i'm ready ^^)

@shivam2112
Copy link

works fine on Chrome and Firefox but not on Safari (iOS or MacOS). I am getting a “zero sized error” on Safari. I recently had an expired cert but renewed it using Let’s Encrypt. I did not test on Safari after renewal as it worked fine on Chrome.
created wordpress website can solve this problem.
Thanks in advance!

@Mil00Z
Copy link

Mil00Z commented Dec 5, 2021

It's work without SASS process
The hack applies on Firefox Standard (why ? Don't know)
I think some of User Agent specs are the same between Firefox and Safari MacOs

@4leeX
Copy link

4leeX commented Aug 12, 2022

@ntnbst thanks man

@EngineerPlug
Copy link

So can i just plug this in and it will work?

@Mil00Z
Copy link

Mil00Z commented Oct 31, 2022

So can i just plug this in and it will work?

yes, it's work for me so just check the Developer tools on Firefox so the hack appear on sometimes :)

@dkoutevska
Copy link

FYI:
@ntnbst's approach works great for desktop browsers, but it will target every mobile browser on iOS devices. :)

@tettoffensive
Copy link

@ntnbst's approach did not work for me on Safari desktop. It didn't affect any browser. If I remove the "not all", it seems to affect all browsers.

@cynthiaeddy
Copy link

@Valeka - many thanks! your solution worked for me.

@MakerTim
Copy link

MakerTim commented Mar 7, 2024

@supports (-webkit-hyphens: none) {
    @content;
  }

Works fine for me & without errors from linter(s)

@CerealKiller97
Copy link

@MakerTim Thank you so much!!! You made my day!!

@RobinSen2217
Copy link

@MakerTim Thank you very much, good sir!!!

@shanimal
Copy link

shanimal commented Aug 7, 2024

MakerTim 🎉

Safari is a mess. Thank you! Added to my globals...

.media-safari(@rules) {
  @supports (-webkit-hyphens: none) {
    @rules();
  }
}
@import (reference) "../less/index.less";

display: grid;

.media-safari ({
    display: flex;
});

@akshilThumar-toddleapp
Copy link

@MakerTim Thank you very much!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment