首页 > 解决方案 > 有没有办法使用css在html中隐藏没有id或class的元素?

问题描述

所以我有一个问题,将第 n 个元素隐藏在没有 id 但其父 div 有 ID 的 div 中。我想隐藏显示“第二个”的第二个跨度

<div id="example">
  <div>
    <span>First</span>
    <span>Second</span>
  </div>
</div>

标签: htmlcss

解决方案


#example span:nth-of-type(2){
  display:none
}

推荐阅读