IE8 gradient filter not working if a background color exists

前端 未结 9 2242
梦毁少年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

提交回复
热议问题