While conditional comments effectively target Internet Explorer with browser-specific CSS, the challenge remains in targeting Firefox specifically. To address this, seek a solution that avoids browser-sniffing JavaScript and leverages browser capabilities similar to conditional comments.
A solution that meets these criteria is as follows:
@-moz-document url-prefix() { h1 { color: red; } }
This rule targets elements with the url-prefix() function, which is unique to Firefox. It ensures that the CSS rules are applied only in Firefox and not in any other browser, including Internet Explorer, WebKit, or Opera.
To use this rule, simply add it to your CSS file. When the browser renders it in HTML, the
This solution relies solely on browser capabilities, providing a clean and highly specific way to target Firefox without any JavaScript trickery.
Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.
Copyright© 2022 湘ICP备2022001581号-3