Internet Explorer isn't treating non-empty ::before and ::after as children elements

左心房为你撑大大i 提交于 2019-12-13 02:27:25

问题


My span has visibility: hidden; applied to it, and it has non-empty ::before and ::after pseudo-elements that aren't respecting the visibility: visible; property in Internet Explorer (all versions) as they should be. What's causing this to happen?

span {
    display: block;
    height: 8px;
    width: 50px;
    background: black;
    position: absolute;
    top: 24px;
    visibility: hidden;
}
span::before, span::after {
    content:"asdf";
    position: absolute;
    display: block;
    left: 0;
    width: 50px;
    height: 8px;
    background: black;
    visibility: visible;
}
span::before {
    top: -15px;
}
span::after {
    bottom: -15px;
}
<span></span>

JSFiddle Demo

According to the W3C specification:

When their computed content value is not none, these pseudo-elements generate boxes as if they were immediate children of their originating element, and can be styled exactly like any normal document-sourced element in the document tree. They inherit any inheritable properties from their originating element; non-inheritable properties take their initial values as usual.

(emphasis mine)

According to Microsoft's Developer Network (MSDN):

As of Microsoft Internet Explorer 5, a child object can be visible when its parent is hidden.

So is this a bug where IE is failing to treat non-empty pseudo-elements as children, or am I missing something?


回答1:


This does indeed appear to be a bug with IE's handling of pseudo-elements and the visibility property. Microsoft was able to reproduce it in response to this issue.

It's worth noting that Microsoft Edge does not appear to exhibit this bug.



来源:https://stackoverflow.com/questions/33725540/internet-explorer-isnt-treating-non-empty-before-and-after-as-children-elem

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!