Html 如何仅显示具有相同名称的一个类
在我的代码中Html 如何仅显示具有相同名称的一个类,html,css,Html,Css,在我的代码中 <ol class="items"> <li class="item"> <span class="filter-label">Category</span> <span class="filter-value">Fashion</span>
<ol class="items">
<li class="item">
<span class="filter-label">Category</span>
<span class="filter-value">Fashion</span>
<a class="action remove" href="https://www.marketplacedemo.store/online-store?cat=226" title="Remove Category Fashion">
<span>Remove This Item</span>
</a>
</li>
<li class="item">
<span class="filter-label">Category</span>
<span class="filter-value">Deal of day-Home</span>
<a class="action remove" href="https://www.marketplacedemo.store/online-store?cat=109" title="Remove Category Deal of day-Home">
<span>Remove This Item</span>
</a>
</li>
</ol>
但它不起作用
如何仅显示一个类别?非常感谢您提供的任何帮助。您可以使用
:not
选择器来实现这一点
.items li:不是(:第一个子项)。筛选标签{
显示:无;
}
类别
时尚
类别
每日交易之家
.filter-label{
display:none;
}
.items:nth-of-type(1) >.filter-label:first-child {
display:block;
}