我想在原始div上设置div的伪元素。居中伪元素
问题是div的文本居中。
下面是一个例子:
#a:after{
content:"Text";
position:absolute;
left:0;
color:red;
}
<div style="width:100%;text-align:center;">
<p id="a">Text</p>
</div>
为什么伪元素不受div样式?
因为你已经使用'位置将其定位:absolute',没有一个祖先拥有非“静态”位置属性;所以它相对于视口定位。 –
@DavidThomas确定在undestand。但我需要绝对位置覆盖这两个文本。 – nicoschuck