IE8 gradient filter not working if a background color exists

前端 未结 9 2203
梦毁少年i
梦毁少年i 2020-12-28 08:53

I\'m trying to use the following CSS styles. They are working on most browsers, including ie7. However in ie8, the transparent background does not show and instead I get th

相关标签:
9条回答
  • 2020-12-28 09:19

    you can use the -ms-filter but i guess its the same issue as opacity if you do filter before -ms-filter it fails se more at:

    http://www.quirksmode.org/css/opacity.html for that theory

    so you need to do like this:

    background-color: #D5D6D7;
    background-image: linear-gradient(bottom, rgb(213,214,215) 0%, rgb(251,252,252) 100%);
    background-image: -o-linear-gradient(bottom, rgb(213,214,215) 0%, rgb(251,252,252) 100%);
    background-image: -moz-linear-gradient(bottom, rgb(213,214,215) 0%, rgb(251,252,252) 100%);
    background-image: -webkit-linear-gradient(bottom, rgb(213,214,215) 0%, rgb(251,252,252) 100%);
    background-image: -ms-linear-gradient(bottom, rgb(213,214,215) 0%, rgb(251,252,252) 100%);
    background-image: -webkit-gradient(
        linear,
        left bottom,
        left top,
        color-stop(0, rgb(213,214,215)),
        color-stop(1, rgb(251,252,252))
    );
    -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#D5D6D7',EndColorStr='#FBFCFC')";
    filter: progid:DXImageTransform.Microsoft.gradient( startColorstr='#D5D6D7', endColorstr='#FBFCFC');
    

    this works for me

    besides that you cant have a 8 char hexcode (hex is latin for six) and on top of this you have the same color to gradient between you have to have different colors

    0 讨论(0)
  • 2020-12-28 09:25

    You're using Modernizer wrong. Modernizer places classes on the HTML element; not each individual element. Here's what I used in IE8 to color the SECTION tags.

    .rgba section {
        background-color: rgba(200, 0, 104, 0.4);
    }
    .no-rgba section {
        background-color: #B4B490;
    }
    .no-cssgradients section {
        filter: progid:DXImageTransform.Microsoft.gradient(startColorStr='#99B4B490',EndColorStr='#99B4B490');
        -ms-filter: "progid:DXImageTransform.Microsoft.gradient(startColorStr='#99B4B490',EndColorStr='#99B4B490')";
        zoom: 1;
    }
    
    0 讨论(0)
  • 2020-12-28 09:30

    It appears, you have to put either width or height to DIV CSS for gradient to work in IE 7+ ( at least I had to )

    .widget-header {
    
        text-align: center;
        font-size: 18px;
        font-weight: normal;
        font-family: Verdana;
        padding: 8px;
        color: #D20074;
        border-bottom: 1px solid #6F6F6F;
        height: 100%;
        /* Mozilla: */
        background: -moz-linear-gradient(top, #FFFFFF, #E2E2E2); 
        /* Chrome, Safari:*/
        background: -webkit-gradient(linear, left top, left bottom, from(#FFFFFF), to(#E2E2E2));
        /* MSIE */
        filter : progid:DXImageTransform.Microsoft.gradient(startColorstr='#FFFFFF', endColorstr='#E2E2E2');
        /* Opera 11.10 + */
        background-image: -o-linear-gradient(top, #FFFFFF, #E2E2E2);
    }
    

    Hope this helps

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