如何使用 CSS 隱藏<div >我的 UL/LI 串列中的每一個,除了第一個,但保留所有<span >
<div id="rpwwt-recent-posts-widget-with-thumbnails-2" class="rpwwt-widget">
<h4 class="widget-title penci-border-arrow"><span class="inner-arrow">WIDGET TITLE</span></h4>
<ul>
<li>
<span class="rpwwt-post-title">TITLE #1</span>
<div class="rpwwt-post-excerpt">POST EXCERPT TO SHOW</div>
</li>
<li>
<span class="rpwwt-post-title">TITLE #2</span>
<div class="rpwwt-post-excerpt">POST EXCERPT TO HIDE</div>
</li>
<li>
<span class="rpwwt-post-title">TITLE #3</span>
<div class="rpwwt-post-excerpt">POST EXCERPT TO HIDE</div>
</li>
<li>
<span class="rpwwt-post-title">TITLE #4</span>
<div class="rpwwt-post-excerpt">POST EXCERPT TO HIDE</div>
</li>
</ul>
</div>
uj5u.com熱心網友回復:
在您的選擇器中,使用:not(:first-child)祖先上的偽類從匹配選擇器中li排除<li>串列中的第一個 - 即使樣式規則最終只影響div.rpwwt-post-excerpt元素。
像這樣:
li:not(:first-child) div.rpwwt-post-excerpt {
display: none;
}
uj5u.com熱心網友回復:
只是選擇 li 不是第一胎。
使用 :not for is not ,并使用 first-child 選擇第一個元素。
所以,ul li:not(:first-child) { display:none; }
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/344724.html
