如何将特定的CSS规则仅应用于Chrome? [英] How to apply specific CSS rules to Chrome only?
本文介绍了如何将特定的CSS规则仅应用于Chrome?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有一个特定的 DIV ,我想将 CSS 添加到
There's a specific DIV that I would like to add the following to its CSS
position:relative;
top:-2px;
但我只想在Google Chrome中应用这个。
But I only want to apply this in Google Chrome. How can I do this?
推荐答案
CSS解决方案
来自 https://jeffclayton.wordpress.com/2015/08/10/1279/
/* Chrome, Safari, AND NOW ALSO the Edge Browser and Firefox */
@media 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屋!
查看全文