【问题标题】:How to fix incorrect display of the nested grouping symbol in the "details" tag?如何修复“详细信息”标签中嵌套分组符号的错误显示?
【发布时间】:2021-08-25 04:40:50
【问题描述】:

如果顶层展开,那么所有嵌套层都被分配“-”符号,即使它们被折叠: jsfiddle.net/acces969/4eh6puvk/1/

<div class="treeHTML">Root
  <div>level 1
    <details><summary></summary>
      <div >level 2
        <details><summary></summary>
          <div >
            level 3
          </div>
        </details>
      </div>
    </details>
  </div>
</div>

【问题讨论】:

    标签: html css hierarchy


    【解决方案1】:

    您的开放细节的 CSS 选择器有点偏离:

    .treeHTML details[open] summary:before {/* styles */}
    

    这将选择所有 summary 元素,它们是开放详细信息元素的子元素(包括非直接子元素)

    要仅选择打开的详细信息的直接子级,您应该使用&gt; 选择器:

    .treeHTML details[open] > summary:before {/* styles */}
    

    【讨论】:

    • 哇。非常感谢,你帮了很多忙。问题解决了,我现在知道这个选择器的作用了(我以前见过很多)
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-06-27
    相关资源
    最近更新 更多