【问题标题】:hide first span and label in a div with css [duplicate]使用css在div中隐藏第一个跨度和标签[重复]
【发布时间】:2021-02-03 19:44:00
【问题描述】:

我正在使用一个不知道如何编辑的 js 程序。它为我的需要输出冗余代码所以我想知道是否有一种方法可以在特定的 div 中隐藏第一个标签和它的输出的第一个跨度。这是输出

<div class="rnTotalBox">
    <label></label>  //hide this 
    <span class="price rn-price "> //hide this
        <span class="amount">$0.00</span> //hide this
    </span> //hide this
    <label>Final Total</label><span class="price rn-price ">
        <span class="amount">$0.00</span>
    </span>
</div>

我认为我可以像这样使用 css:

.rnTotalBox label:first-child {
    display:none;
}
.rnTotalBox span:first-child {
    display:none;
}

但无论如何他们都会隐藏一切。有没有办法隐藏第一个标签和第一个跨度?

【问题讨论】:

    标签: html css


    【解决方案1】:

    您可以使用label:first-of-type 选择器!

    https://css-tricks.com/almanac/selectors/f/first-of-type/

    【讨论】:

      猜你喜欢
      • 2021-04-27
      • 1970-01-01
      • 1970-01-01
      • 2014-03-10
      • 2010-12-26
      • 1970-01-01
      • 1970-01-01
      • 2015-09-25
      • 2015-12-05
      相关资源
      最近更新 更多