Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/backbone.js/2.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
更少的CSS访问元素嵌套CSS类_Css_Class_Nested_Less - Fatal编程技术网

更少的CSS访问元素嵌套CSS类

更少的CSS访问元素嵌套CSS类,css,class,nested,less,Css,Class,Nested,Less,在本例中,我试图仅访问toc第1章的元素。元素位于嵌套类中。我在toc部分使用了这种方法,并且能够产生想要的结果 Css: HTML: 根据您提供的信息,我假设LESS正在生成以下css选择器。我实际上没有在LESS中记录您的问题,这只是我的解释: .book .toc a.target-chapter .cnx-gentext-n:before {content: "testing";} 这应该行得通。我假设您正在一个支持旧版本IE的浏览器中进行测试。因此,要解决此问题,您需要: 验证是否确

在本例中,我试图仅访问toc第1章的元素。元素位于嵌套类中。我在toc部分使用了这种方法,并且能够产生想要的结果

Css:

HTML:


根据您提供的信息,我假设LESS正在生成以下css选择器。我实际上没有在LESS中记录您的问题,这只是我的解释:

.book .toc a.target-chapter .cnx-gentext-n:before {content: "testing";}
这应该行得通。我假设您正在一个支持旧版本IE的浏览器中进行测试。因此,要解决此问题,您需要:

验证是否确实正在生成这样的选择器。 如果没有,请确定代码实际生成的选择器字符串(如果有),这可能会导致您解决问题。 如果正在生成这样一个正确的选择器字符串,那么您需要查看您尚未发布的其他css,因此我只是在这里推测:

是否有更具体的选择器字符串指向相同的对象并覆盖它? 您是否在其他地方设置了显示、颜色、可见性或其他属性:before伪元素,该伪元素实际上隐藏了添加的测试? 您的实际用例是否将图像作为内容,并且您是否看到它没有显示在打印中,这将是一个完全不同的问题?
基本上,如果您的选择器字符串显示正确,那么可能会发生许多其他事情,我们需要更多细节来解决它。如果它不是如上所述,那么我想知道它在生产什么。

到底是什么问题?是红色还是未应用内容?另外,我在html中没有看到.book类,可能是缺少了。这个问题似乎不完整,因为毫无疑问book类在html中,我没有将它包含在.toc之前的代码段中。应用红色,但cnx-gentext-n前不显示文字testing。就好像没有访问该元素一样。我的问题是如何访问它。
<div class="toc">
  <div class="title">
    Table of Contents
  </div>

  <ul>
    <li xmlns:d="http://docbook.org/ns/docbook" xmlns:db=
    "http://docbook.org/ns/docbook" xmlns:pmml2svg=
    "https://sourceforge.net/projects/pmml2svg/" xmlns:c="http://cnx.rice.edu/cnxml"
    xmlns:ext="http://cnx.org/ns/docbook+" xmlns:svg="http://www.w3.org/2000/svg"
    xmlns:mml="http://www.w3.org/1998/Math/MathML" class="toc-chapter">
      <a href="#idm3792312" class="target-chapter"><span class=
      "cnx-gentext-chapter cnx-gentext-autogenerated">Chapter</span> <span class=
      "cnx-gentext-chapter cnx-gentext-n">1</span><span class=
      "cnx-gentext-chapter cnx-gentext-autogenerated">.</span> <span class=
      "cnx-gentext-chapter cnx-gentext-t">Aging and the Elderly</span></a>
.book .toc a.target-chapter .cnx-gentext-n:before {content: "testing";}