Detecting IE11 with CSS Capability/Feature Detection
Identifying the specific version of Internet Explorer is often necessary for browser-specific enhancements or workarounds. While IE10 detection can be achieved using CSS capability detection, it can be challenging to differentiate between IE10 and IE11.
One possible solution involves leveraging undocumented CSS properties and values introduced exclusively in IE11. Here are some potential properties to consider:
By combining these properties, we can create CSS rules that are specific to IE11:
_:-ms-fullscreen, :root .ie11up { property: value; }
This rule will only apply styles to elements when either the _:-ms-fullscreen property or the .ie11up class is present, ensuring that it only targets IE11 or later versions of the browser.
However, it's important to note that browser-detection hacks can introduce potential issues and are generally discouraged. The primary recommendation is to use modernizr.js, a JavaScript library for feature detection, or to consider platform-based CSS selectors to avoid relying on unsupported methods.
The above is the detailed content of How Can I Reliably Detect Internet Explorer 11 Using CSS?. For more information, please follow other related articles on the PHP Chinese website!