div { position: relative; width: 100px; height: 100px; background: #f00; }
div::before { position: absolute; content: ''; width: 75px; height: 75px; background: #0f0; }
div::before::before { position: absolute; content: ''; width: 50px; height: 50px; background: #00f; }
我的语法是否有误或者伪元素内嵌伪元素不被支持?
请注意,我知道::after
伪元素,但是我需要在另一个伪元素内部使用实际元素,例如:::after
无法满足以下要求:
div { position: relative; width: 100px; height: 100px; background: #f00; }
div::before { position: absolute; content: ''; right: 0; bottom: 0; width: 75px; height: 75px; background: #0f0; }
div::after { position: absolute; content: ''; left: 0; top: 0; width: 50px; height: 50px; background: #00f; }
因为
::after
与元素相关,而不是::before
。