I want the background picture not to be displayed in the IE. How do I do that?

后端 未结 8 1459
暗喜
暗喜 2020-12-22 05:04

Here\'s the CSS , and I want the background picture not to be displayed in IE . Instead I just want the background color to be displayed. How do I do that?

h         


        
相关标签:
8条回答
  • 2020-12-22 05:34

    There is obviously multiple ways to answer this question, some good methods already mentioned. Here is another method that I use most often and it requires less bytes:

    To target only Internet Explorer, put an "*" in front of the code that you want to target for I.E. Using your example above, for the background to not appear in I.E. use the * like so:

        html, body {    
        margin:0;
        padding: 0;    
        background: #a9ac41;
       *background-image: none;  
        background-image: url("background.png");    
        background-repeat: no-repeat;
        background-size: cover;    
        margin:0;
    

    If and when it doesn't work, likely your rules are conflicting. In such cases, use "!important", like so:

        *background-image: none !important;
    
    0 讨论(0)
  • 2020-12-22 05:36

    replace the tag html of your HTML for this:

    <!-- paulirish.com/2008/conditional-stylesheets-vs-css-hacks-answer-neither/ -->
    <!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7" lang="en"> <![endif]-->
    <!--[if IE 7]>    <html class="no-js lt-ie9 lt-ie8" lang="en"> <![endif]-->
    <!--[if IE 8]>    <html class="no-js lt-ie9" lang="en"> <![endif]-->
    <!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
    

    then in the css:

        html,body{      
          margin:0;
          padding: 0;
    
          background-image: url("background.png");
    
          background-repeat: no-repeat;
          background-size: cover; 
    
          margin:0;
          padding: 0;     
        }
    
    html.lt-ie9,html.lt-ie9 body{
          background: #a9ac41;
          background-image: none;
    }
    

    Note: IE10 doesn't support conditional comments son this method works in < IE9.

    0 讨论(0)
提交回复
热议问题