How do I add a css line ONLY for Safari

后端 未结 7 1535
轮回少年
轮回少年 2020-12-28 11:03

I am making a website, but an element needs margin in Chrome and other browsers, but not in safari. So I want to add a css line to fix it, but I can\'t find any method to ad

7条回答
  •  眼角桃花
    2020-12-28 11:13

    In safari 9.0 (only, not > 9.0) you can do it now in CSS with this nice hack. You don't need any JS code. I did it and its working fine for me. Use this hack:

    @supports (overflow:-webkit-marquee) and (justify-content:inherit) {
    
    /* type your custom css code here */
    
    }
    

    The reason it is working is: Safari 9.0 and above have feature detection. So by detecting a feature which is exclusively for Safari you can detect Safari. overflow:-webkit-marquee and justify-content:inherit are exclusively for safari. Thats why we can detect safari with this simple CSS hack.

提交回复
热议问题