我想使用last-of-type选择两个元素,但是我不知道正确的语法是什么。如果这是html:
<div class="Box">
<book class="small"/>
<book class="small"/>
<notes/>
<notes/>
<toy class="small"/>
<toy class="small"/>
</div>
我想在Box中选择最后一本书和最后一个玩具,语法是什么?我虽然会是:
div.Box book.small, toy.small:last-of-type { }
但这显然是不正确的。
最佳答案
您必须将属性last-of-type
应用于两个选择器:
div.Box book.small:last-of-type, toy.small:last-of-type
关于css - CSS的最后一个类型,带有多个选择器,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/34951221/