[英]Pseudo-element formatting not working
I have this CSS:我有这个 CSS:
sqrt::before {
border: none;
content: "√";
}
sqrt {
content: attr(expr);
border-top: 1px solid black;
}
The ::before
pseudo-element has a border. ::before
伪元素有一个边框。
I intentionally specified border: none;
我特意指定了border: none;
to avoid this.为了避免这种情况。
There is no border on the ::before
. ::before
上没有边界。 The issue is that your ::before
-element is inside the sqrt
-element.问题是您的::before
-element 位于sqrt
-element 内。
Try this code:试试这个代码:
sqrt::before {
border: none;
content: "√";
position: absolute;
left: 0;
}
sqrt {
content: attr(expr);
border-top: 1px solid black;
margin-left:2px;
}
It positions the ::before
absolute to the sqrt
-element, and moves the sqrt
-element away from the ::before
, therefore creating the desired effect.它将::before
绝对定位到sqrt
元素,并将sqrt
元素从::before
移开,从而创建所需的效果。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.