Html 伪元素格式设置不起作用
我有这个CSS:Html 伪元素格式设置不起作用,html,css,pseudo-element,Html,Css,Pseudo Element,我有这个CSS: sqrt::before { border: none; content: "√"; } sqrt { content: attr(expr); border-top: 1px solid black; } ::before伪元素有边框 我故意指定边框:无以避免这种情况。在之前的::上没有边框。问题是您的::before-元素在sqrt-元素中 请尝试以下代码: sqrt::before { border: none; content: "√";
sqrt::before {
border: none;
content: "√";
}
sqrt {
content: attr(expr);
border-top: 1px solid black;
}
::before
伪元素有边框
我故意指定
边框:无
以避免这种情况。在之前的::上没有边框。问题是您的::before
-元素在sqrt
-元素中
请尝试以下代码:
sqrt::before {
border: none;
content: "√";
position: absolute;
left: 0;
}
sqrt {
content: attr(expr);
border-top: 1px solid black;
margin-left:2px;
}
它将::before
绝对定位到sqrt
-元素,并将sqrt
-元素移离::before
,从而创建所需的效果
并且sqrt有一个边界。。。向我们展示你期望的html和数据,等等什么是sqrt,问题是什么?@Temaniaff:只需将一些文本包装在sqrt标记中。@manishkumar:1。这是“平方根”的简写。