treehouse : what would you like to learn today?
Web Design Web Development iOS Development

[Solved] Target IE9?

  • I have a question is there a way to target IE9 in a gradient background setup so IE9 will have a plane background like so?

    body {
      color: #00000;
      /* IE10 Consumer Preview */ 
    background-image: -ms-linear-gradient(top, #FFFFFF 0%, #4E0700 100%);
      /* Mozilla Firefox */ 
    background-image: -moz-linear-gradient(top, #FFFFFF 0%, #4E0700 100%);
      /* Opera */ 
    background-image: -o-linear-gradient(top, #FFFFFF 0%, #4E0700 100%);
      /* Webkit (Safari/Chrome 10) */ 
    background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #FFFFFF), color-stop(1, #4E0700));
      /* Webkit (Chrome 11+) */ 
    background-image: -webkit-linear-gradient(top, #FFFFFF 0%, #4E0700 100%);
      /* W3C Markup, IE10 Release Preview */ 
    background-image: linear-gradient(to bottom, #FFFFFF 0%, #4E0700 100%);
    
    /* IE9 Consumer Preview */
    
    background-color: #FFFFFF; (note this is the bg i want only IE to have but this doesnt work)
    
    background-color: #4E0700; (note this the color i want all the other browsers to have b.c the gradient isnt repeating down)
    
    background-repeat:no-repeat;
    
    margin: 0px;
    

    }

    To see live :: http://fiveproduction.com/fch/

  • Here's the code I use to target specific IE browsers on my website

    http://codepen.io/anon/pen/Jpzmo

    EDIT -> it goes in the head of the HTML file

  • A method I use to target browsers:

    HTML

    <!--[if IE 7 ]> <body class="ie7> <![endif]--> 
    <!--[if IE 8 ]> <body class="ie8> <![endif]--> 
    <!--[if gt IE 8]><!--><body><!--<![endif]-->
    

    Then, in the CSS:

    .somediv {
    width:500px;
    }
    
    .ie7 .somediv {
    width:450px;
    }
    

    In the above example, IE7 will show somediv at 450px, while all other browsers will show it at 500px.

    Side point: If a gradient is what you're after in IE, you can use the ugly-ass lump code below (note: It doesn't play nice with border-radius):

    filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#ed1c24', endColorstr='#aa1317');