伪元素格式化不起作用

时间:2018-03-06 09:46:20

标签: html css pseudo-element

我有这个CSS:

sqrt::before {
  border: none;
  content: "√";
}
sqrt {
  content: attr(expr);
  border-top: 1px solid black;
}

::before伪元素有边框。

我故意指定border: none;来避免这种情况。

1 个答案:

答案 0 :(得分:0)

::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 - 元素移离public String loadJSONFromAsset() { String json = null; try { InputStream is = getActivity().getAssets().open("yourfilename.txt"); int size = is.available(); byte[] buffer = new byte[size]; is.read(buffer); is.close(); json = new String(buffer, "UTF-8"); } catch (IOException ex) { ex.printStackTrace(); return null; } return json; } ,从而创建所需的效果。

Working JSFiddle