I need to hide a background element in my css for IE.
This is the class in the css file
.navbar-header .nav #presentacion {
background:url("../img/horiz-line.png") no-repeat scroll 108px 20px transparent;
display: block;
height: 20px;
margin-top: 20px;
}
I want to use this method, inserting the CSS in the head section of the page hidding this part :
<!--[if IE]>
<style>
.navbar-header .nav #presentacion {
display: block;
height: 20px;
margin-top: 20px;
background: none;}
</style>
<![endif]-->
It's not working , the background is still displayed in IE, what i am doing wrong?
You can hide an element in CSS using the CSS properties display: none or visibility: hidden . display: none removes the entire element from the page and mat affect the layout of the page. visibility: hidden hides the element while keeping the space the same.
Using display CSS The easiest method of hiding an element is to remove it entirely. The display:none property does just that. It removes whatever element you attach it to completely. That piece of the page will simply not render anymore, and the space it takes up on the page will be removed and the layout readjusted.
#2 CSS Rules Specific to Explorer (IE CSS hacks) IE8 or below: to write CSS rules specificially to IE8 or below, add a backslash and 9 ( \9 ) at the end before the semicolon. IE7 or below: add an asterisk ( * ) before the CSS property. IE6: add an underscore ( _ ) before the property.
To hide an element, set the style display property to “none”. document. getElementById("element"). style.
Use the reverse method. Apply !IE class to the class you want to display background image. this gets rendered only in non-IE browsers.
<!--[if !IE]> -->
<style>
.navbar-header .nav #presentacion {
background:url("../img/horiz-line.png") no-repeat scroll 108px 20px transparent;
display: block;
height: 20px;
margin-top: 20px;
}
</style>
<!-- <![endif]-->
IE 10 + does not support conditionnal style. So you must use this for IE10+:
<style>
@media all and (-ms-high-contrast: none), (-ms-high-contrast: active) {
/* IE10+ styles */
.navbar-header .nav #presentacion {
display: block;
height: 20px;
margin-top: 20px;
background: none;}
}
</style>
More info here: How do I target only Internet Explorer 10 for certain situations like Internet Explorer-specific CSS or Internet Explorer-specific JavaScript code?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With