Restrict CSS to IE

Asked

Viewed 57 times

3

Is something missing in this parameter ? I need this style to apply to IE 11 only, when I include this code it works, but other browsers tbm take

<!-- [if gte IE 8]-->
    <style>
        .box-form .logo-footer {
            margin-top: -2vh!important;
            margin-bottom: -9vh!important;
            margin-left: 44px!important;
        }
    </style>
<!--[endif]-->

1 answer

2


Only for IE10 and IE11 you can do so!

@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    .box-form .logo-footer { 
        margin-top: -2vh!important;
        margin-bottom: -9vh!important;
        margin-left: 44px!important;
    }
}

Here is a more complete documentation.

https://gist.github.com/vidaaudrey/c16774076391d09e7ec7dbb7ed7a3189

Test Hack on IE11 on Windows 10 and Chrome 63

In Chrome 63 inserir a descrição da imagem aqui

In IE 11, note the red square at the bottom right corner "11" inserir a descrição da imagem aqui

Code I used

<style>
.teste {
    width: 100px;
    height: 100px;
    background-color: red;
}
@media screen and (-ms-high-contrast: active), (-ms-high-contrast: none) {
    .teste { 
        width: 100px;
        height: 100px;
        background-color: black;
    }
}
</style>
</head>

<body>

    <div class="teste"></div>

</body>
  • Good Hugo ! But here did not catch, I’m reading the documentation to see if I find something, but still nothing =/

  • 1

    In this documentation have for all ies here on my machine running Windows 10 worked on IE11 without problems. Remember to put this code inside the <style></style>

  • Hugo ! Saved my life ! I was using in external css, did not know it needed to be embedded ... Rigadão saw !

  • @Flavia, I’m glad it worked out! If my reply helped you in any way consider marking the Reply with "Accept".

Browser other questions tagged

You are not signed in. Login or sign up in order to post.