Can you use rgba colours in gradients produced wit

2019-01-26 18:42发布

Internet Explorer’s filter CSS property (-ms-filter from IE 8) allows you to do CSS gradients, a bit like the -webkit-gradient and -moz-gradient properties (see e.g. question 213750).

However, the syntax doesn’t seem to allow for rgba colours, so you can’t do a gradient from a colour to transparent.

Is there any way to achieve gradients that end in transparency in IE?

1条回答
放我归山
2楼-- · 2019-01-26 19:10

Stop colors can be specified in #AARRGGBB notation, where AA represents the alpha. For example, #ffff0000 is fully-opaque red.

This produces a 100% red to 50% black horizontal gradient:

filter: progid:DXImageTransform.Microsoft.Gradient(
    GradientType=1, 
    StartColorStr='#ffff0000', 
    EndColorStr='#80000000'
);

jsFiddle preview

查看更多
登录 后发表回答