Internet Explorer CSS property “filter” ignores overflow:visible

前端 未结 2 553
别那么骄傲
别那么骄傲 2021-02-13 13:36

Apparently Internet Explorer (up to version 8 at least) ignores overflow:visible when applying filter (e.g. for opacity), causing anything outside the filtered

2条回答
  •  梦毁少年i
    2021-02-13 14:05

    First, one interesting note: IE9 seems to correctly honor overflow:visible, even when emulating IE8.

    Second, one general workaround to this issue would be to make your #container and #child siblings of one another inside of a common parent. The common parent would have no filter (meaning overflow will function correctly), and you would apply the filter you need to #container.

    Because #child is no longer really a child of container, however, it will not receive your filter. This may or may not be a problem, and one possible solution is to apply the same filter to #child as well. I say this is a "possible solution" because applying the filter to the two elements independently, then composing them may or may not be identical to composing the elements first, then applying the filter to that composition. It depends what the filter is, and on whether or not the elements overlap. Even if it is not identical, it might be "close enough."

    Finally, if your page has a doctype that puts it into standards mode (instead of the quirks mode to which IE defaults when there is no doctype), you may notice that filters do not apply to child elements unless the child has position:static (the default when no position is specified). Specifying either position:absolute or position:relative on the child will cause the filter on the parent not to apply to the child. Generally, this is a bad thing, but a side effect is that it will cause overflow:visible to work correctly.

    If you adopt this solution, you will have the same problem that you may need to apply the filter to the child element as well.

提交回复
热议问题