如何仅将特定的 CSS 规则应用于 Chrome? [英] How to apply specific CSS rules to Chrome only?

查看:51
本文介绍了如何仅将特定的 CSS 规则应用于 Chrome?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法仅在 Google Chrome 中将以下 CSS 应用于特定的 div?

Is there a way to apply the following CSS to a specific div only in Google Chrome?

position:relative;
top:-2px;

推荐答案

CSS 解决方案

来自 https://jeffclayton.wordpress.com/2015/08/10/1279/

/* Chrome, Safari, AND NOW ALSO the Edge Browser and Firefox */
@media screen and (-webkit-min-device-pixel-ratio:0) {
  div{top:10;} 
}

/* Chrome 29+ */
@media screen and (-webkit-min-device-pixel-ratio:0)
  and (min-resolution:.001dpcm) {
    div{top:0;} 
}

/* Chrome 22-28 */
@media screen and(-webkit-min-device-pixel-ratio:0) {
  .selector {-chrome-:only(; 
     property:value;
  );} 
}

JavaScript 解决方案

if (navigator.appVersion.indexOf("Chrome/") != -1) {
// modify button 
}

这篇关于如何仅将特定的 CSS 规则应用于 Chrome?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆