Gradient colors in Internet Explorer

前端 未结 11 653
青春惊慌失措
青春惊慌失措 2020-12-04 09:31

I know that Internet Explorer has some proprietary extensions so that you can do things like create divs with a gradient background. I can\'t remember the element name or i

相关标签:
11条回答
  • 2020-12-04 09:59

    Look at the custom CSS filters IE can handle http://msdn.microsoft.com/en-us/library/ms532847.aspx

    0 讨论(0)
  • 2020-12-04 10:01

    Note that IE10 will support gradients as follows:

    background: -ms-linear-gradient(#017ac1, #00bcdf);
    
    0 讨论(0)
  • 2020-12-04 10:03

    Two things I discovered while struggling with IE 9 gradient.

    1. The -ms-filter did not work for me. I had to use simply filter.
    2. I had to add height: 100% to my class for IE to use the gradient.
    0 讨论(0)
  • 2020-12-04 10:06

    A significant gotcha when it comes to gradients in IE is that although you can use Microsoft's filters...

    filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#FCCA6D', endColorstr='#FEFEFE');
    zoom:1;
    

    ...they kill clear type on any text covered by the gradient. Given that the purpose of gradients is normally to make the UI look better, that's a show stopper for me.

    So for IE I use a repeating background image instead. If the background image css is combined with the gradient CSS for other browsers (as per Blowsie's answer), other browsers will ignore the background image in favour of the gradient css, so it will only end up applying to IE.

    background-image: url('/Content/Images/button-gradient.png');
    

    There are plenty of sites you can use to quickly generate a gradient background; I use this.

    0 讨论(0)
  • 2020-12-04 10:06

    Great tool from Microsoft, allows you to examine colors real-time and generates CSS for all browsers: http://ie.microsoft.com/testdrive/graphics/cssgradientbackgroundmaker/default.html

    /* IE10 */ 
    background-image: -ms-linear-gradient(top, #FFFFFF 0%, #B7B8BD 300%);
    
    /* Mozilla Firefox */ 
    background-image: -moz-linear-gradient(top, #FFFFFF 0%, #B7B8BD 300%);
    
    /* Opera */ 
    background-image: -o-linear-gradient(top, #FFFFFF 0%, #B7B8BD 300%);
    
    /* Webkit (Safari/Chrome 10) */ 
    background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #FFFFFF), color-stop(3, #B7B8BD));
    
    /* Webkit (Chrome 11+) */ 
    background-image: -webkit-linear-gradient(top, #FFFFFF 0%, #B7B8BD 300%);
    
    /* Proposed W3C Markup */ 
    background-image: linear-gradient(top, #FFFFFF 0%, #B7B8BD 300%);
    
    0 讨论(0)
提交回复
热议问题