简体   繁体   English

奇怪的行为:显示表+伪元素后

[英]Strange behavior : display table + after pseudo-element

I noticed a strange phenomenon when I apply an :after pseudo-element on an element with display:table as you can see here : http://jsfiddle.net/rKzNv/1/ 当我在具有display:table的元素上应用:after伪元素时,我注意到一个奇怪的现象,如您在此处看到的: http : //jsfiddle.net/rKzNv/1/

The pseudo-element may behave like a table cell when it should not. 伪元素应该在不应该像表单元格的情况下那样运行。

Do you have any idea? 你有什么主意吗? Is this a bug? 这是错误吗? Thanks! 谢谢!

From MDN - ::after (:after) 来自MDN-:: after(:after)

The CSS :after pseudo-element matches a virtual last child of the selected element. CSS:after伪元素与所选元素的虚拟最后一个子项匹配。

So .table:after matches a virtual child of div.table , which is allowed to behave as a table cell. 因此.table:after匹配.table:after的虚拟 div.table ,该 div.table可以用作表单元格。

The behaviour changes, when you replace display: table-cell; 替换display: table-cell;时,行为会发生变化display: table-cell; with display: table-row; display: table-row;

http://jsfiddle.net/rKzNv/2/ http://jsfiddle.net/rKzNv/2/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM