Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/76.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Html 伪元素格式设置不起作用_Html_Css_Pseudo Element - Fatal编程技术网

Html 伪元素格式设置不起作用

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: "√";

我有这个CSS:

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。这是“平方根”的简写。