Why does a filter gradient on a pseudo element not work in IE8?

后端 未结 5 2337
难免孤独
难免孤独 2020-11-27 17:41

I want to create buttons like these:

In modern browsers the effect is created using inset box-shadow and filters.
For IE8 - pseudo-elements are chosen.

5条回答
  •  暖寄归人
    2020-11-27 18:00

    The question is "Why don't filters work on pseudo elements in IE8?" The following is as close to a definitive answer as I can muster. It comes from the information on this page.

    The gradient filter is a "procedural surface" (along with alphaimageloader). A procedural surface is defined so:

    Procedural surfaces are colored surfaces that display between the content of an object and the object's background.

    Read that carefully. It is essentially another "layer" you might say between the content of an object and that object's background. Do you see the answer to the question? What is created by :before and :after... Yes! Content. Specifically as MSDN notes:

    The ::before and ::after pseudo-elements specify the location of content before and after an element in the document tree. The content attribute, in conjunction with these pseudo-elements, specifies what is inserted.

    The generated content interacts with other boxes as if they were real elements inserted just inside their associated element.

    Now, if it is content that is generated, then it is not an "object" containing content, but the content itself (which happens to have some behavior similar to an element object that might contain content).

    Thus, there is no "object" containing "content" (since it is content) between which the filter can place a procedural surface for content generated by a pseudo-element (i.e. "false element"). A gradient must be applied to the object, and then the procedural surface is placed between it and the content.

提交回复
热议问题