Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to apply specific CSS rules to Chrome only?

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

position:relative; top:-2px; 
like image 691
user1213707 Avatar asked Feb 17 '12 13:02

user1213707


People also ask

Can we write browser-specific CSS?

When working with HTML and CSS, it is common to face browser-specific issues for the same web application. Therefore, it becomes necessary to develop browser-specific CSS code to assure a seamless user experience, regardless of the browser they use. CSS Grid: CSS Grid is widely used in web design.

How do I add custom CSS to Chrome?

Go to element panel ( Ctrl + Shift + p and type show element panel). Scroll to the head element right click on the element and choose Edit as HTML, go to the bottom of that element ( Ctrl + End ), add your <style></style> element there add your style in that element, and hit Ctrl + Enter .


1 Answers

CSS Solution

from 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 Solution

if (navigator.appVersion.indexOf("Chrome/") != -1) { // modify button  } 
like image 118
Martin Kristiansson Avatar answered Sep 30 '22 23:09

Martin Kristiansson