Home > Web Front-end > CSS Tutorial > Can I Apply CSS Rules to a Specific Div Only in Google Chrome?

Can I Apply CSS Rules to a Specific Div Only in Google Chrome?

DDD
Release: 2024-12-10 21:59:17
Original
941 people have browsed it

Can I Apply CSS Rules to a Specific Div Only in Google Chrome?

Applying CSS rules exclusively to Google Chrome

Query: Can specific CSS rules be applied to a specific div only in Google Chrome? Here's the example:

position: relative;
top: -2px;
Copy after login

Response: Yes, this is possible, and there are two approaches:

CSS Solution

/* 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;
  );} 
}
Copy after login

JavaScript Solution

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

The above is the detailed content of Can I Apply CSS Rules to a Specific Div Only in Google Chrome?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template