How to load CSS stylesheets only on IE

Foreword: IE has always been a special browser, we can use some methods to specify that the style sheet is only loaded under IE browser.

IE9 and lower than IE9 version:

Conditional comment statements can be used to load style sheets specific to ie. Use an external style sheet as shown below.

<!--[if IE]>
  <link rel="stylesheet" type="text/css" href="all-ie-only.css" />
<![endif]-->

But if it is IE10 or above, this method is not very suitable.

IE10 or IE11:

Use the media query (-ms-high-contrast) to load the style sheet. Since -ms-high-contrast is unique to Microsoft (and only available in IE 10+), it can only be resolved in Internet Explorer 10 or higher.

@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
     /* IE10+ CSS styles go here */
}

Microsoft Edge12: @supports can be used

@supports reference article

@supports (-ms-accelerator:true) {
  /* IE Edge 12+ CSS styles go here */ 
}

to sum up

If we want to load the stylesheet only for IE, just set the conditional comment and the -ms-high-contrast media query.

Intelligent Recommendation

CSS Basics Introduction - defined by CSS stylesheets

1. CSS definitions unordered list of small attack Alignment for unordered list Description Table parameter Explanation disc Solid round circle Hollow circle square Solid squares none no     ...

Dynamic loading with javascript javascript script / css stylesheets

Reproduced in: https: //www.cnblogs.com/heitou/archive/2011/06/21/2086205.html...

Conditional Stylesheets vs CSS Hacks? Answer: Neither!

…or… <html>’s conditional classes From what I’ve seen a good number of developers these days are split between conditional stylesheets and css hacks. You’re ...

About Myeclipse is not recognized (read) part of css stylesheets

Two days before going to write big job, and then spend the semester to write the code found invalid css import (import from external Myeclipse), examined the path, encoding, etc. will not work, I even...

More Recommendation

[CSS] -Cascading styleSheets layered style table

  Table of contents 0. CSS introduction 1. CSS statement composition 2. How to select the CSS selector 1) The method and selector of the CSS selector: 2) Three common methods: 3. Add CSS method 1...

How to load CSS asynchronously

media = ’none‘ οnlοad=“if(media!=‘all’)media=‘all’”...

How to make IE add special CSS style

Useful Oh, so translated, and may not be accurate, but it should not have too much access to the original text. Original Address:http://css-tricks.com/how-to-create-an-ie-only-stylesheet/ If you are r...

How to load a CSS file in HTML?

It can be loaded through the link tag: It can also be loaded by @import Note that using @import to load will cause the CSS file to be loaded after the HTML page is loaded, that is to say, the page is ...

How to load js and css in Odoo11

For example, the code of the "Invoicing" module: ①. Rewrite the following code in the view: Source code reference location: addons/account_invoicing/views/account_invoicing_templates.xml 1~8...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top