None None - 4 months ago 18
CSS Question

How to apply class only for IE?

I have this class in CSS and i need to change it when its IE. I want to remove

padding-bottom
. How can I do that?

I don't want to add another CSS file, I want to change only one property in one class.

.container-wrapp{
float: left;
position: relative;
width: 100%;
padding-bottom:100px;
height: 100%;
}


I tried this but without success:

<!--[if IE]>
<style type="text/css">
.container-wrapp{
float: left;
position: relative;
width: 100%;
height: 100%;
}
</style>
<![endif]-->

Answer

For IE10+ you can do the following:

@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
   .container-wrapp{padding-bottom:0;}
}

Demo Fiddle (Note that the text is red only in IE 10+)

@media all and (-ms-high-contrast: none),
(-ms-high-contrast: active) {
  .red {
    color: red
  }
}
<div class="red">text</div>

NB: Using hacks like these are generally frowned upon. Use with caution.