I
I
Ivan Damaskin2013-11-18 20:44:27
css
Ivan Damaskin, 2013-11-18 20:44:27

Hack for internet explorer 11?

Greetings.
Tell me how to register styles only for internet explorer 11 version.

Answer the question

In order to leave comments, you need to log in

8 answer(s)
D
Denis, 2014-10-21
@Joannes

found a solution without js

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

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

J
Jonh Doe, 2013-11-18
@CodeByZen

My God. What for? Why did you separate Q&A from habr? People got lazy to the edge. Difficult to google. Right there, now there will be a hell of a mess of shit, and not Q&A.

M
Mikhail Osher, 2013-11-18
@miraage

<!--[if IE 11]>
<link rel="stylesheet" href="/css/ie11.css">
<![endif]-->

Not?

P
pomeo, 2013-11-18
@pomeo

browserhacks.com

A
Alexander Nameless08, 2016-06-01
@Nameless08

Yes, in principle, nothing is bad.
You can modify the above script like this:
$().ready(function() {
var ie10Styles = [
'msTouchAction','msWrapFlow','msWrapMargin','msWrapThrough','msOverflowStyle','msScrollChaining',
'msScrollLimit',' msScrollLimitXMin','msScrollLimitYMin','msScrollLimitXMax','msScrollLimitYMax',
'msScrollRails','msScrollSnapPointsX','msScrollSnapPointsY','msScrollSnapType','msScrollSnapX', 'msScrollSnapY',
'msScroll'FlexTranslation','msScrollFlexTranslation','msScrollFlexTranslation','msScrollFlexTranslation' ,'msFlexOrder'
];
var ie11Styles = [
'msTextCombineHorizontal'
];
/*
* Test all IE only CSS properties
*/
var d = document;
varb = d.body;
var s = b.style;
var ieVersion = null;
var property;
// Test IE10 properties
for (var i = 0; i < ie10Styles.length; i++) {
property = ie10Styles[i];
if (s[property] != undefined) {
$('body').addClass("ie-10");
}
}
// Test IE11 properties
for (var i = 0; i < ie11Styles.length; i++) {
property = ie11Styles[i];
if (s[property] != undefined) {
if ($('body').hasClass("ie-10")) {
$('body').removeClass("ie-10").addClass("ie -eleven");
}
else {
$('body').addClass("ie-11");
});

T
taxblp, 2019-10-15
@taxblp

_:-ms-fullscreen, :root .CLASS-NAME {
}
here is the CSS solution

I
intmain, 2013-11-18
@intmain

And conditional compilation is not suitable?
That is, if you write in js:

/*@cc_on
.... // тут код, который видят и исполняют только IE, остальные браузеры считают за комментарии
@*/

Of course, you need to take into account that the code inside cc_on will be executed by all IEs, not only the 11th one. And the task is to distinguish it. But inside the code, you can use checks like /*@if (@_jscript_version >= ... ) I think it's not difficult to find which specific number for IE11.

A
Andrey Chernyshev, 2013-11-19
@delch

And why is the option with js bad if there are no others on the horizon?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question