Html CSS:仅显示列表中的最后x项
是否可以使用纯CSS仅显示列表中的最后x项 下面的代码片段显示了除前2项之外的所有项。如何仅显示列表中的最后两项Html CSS:仅显示列表中的最后x项,html,css,Html,Css,是否可以使用纯CSS仅显示列表中的最后x项 下面的代码片段显示了除前2项之外的所有项。如何仅显示列表中的最后两项 ul li { display: none !important; } ul li:nth-of-type(2) ~ li { display: inherit !important; } 简单使用 使用:最后一种类型的第n个(-n+x)或:第n种类型的第n个(-n+x) ul li:nth-last-of-type(2), ul li:nth-last-of-
ul li {
display: none !important;
}
ul li:nth-of-type(2) ~ li {
display: inherit !important;
}
简单使用
使用:最后一种类型的第n个(-n+x)
或:第n种类型的第n个(-n+x)
ul li:nth-last-of-type(2),
ul li:nth-last-of-type(2) ~ li {
display: inherit !important;
}