美文网首页
ul的li第一个和最后一个的样式特殊处理

ul的li第一个和最后一个的样式特殊处理

作者: 没有卢果 | 来源:发表于2019-11-22 09:18 被阅读0次

第一个li的样式:li:first-child { background:#f00; }
最后一个li的样式:li:last-child { background:#000; }
第n个li的样式:li:nth-child(n) { background:#000; }
倒数第二个li的样式:nth-last-of-type(2){ background:#000; }
奇数列表:li:nth-child(odd) { background:#f00; }
偶数列表:li:nth-child(even) { background:#f00; }

相关文章

网友评论

      本文标题:ul的li第一个和最后一个的样式特殊处理

      本文链接:https://www.haomeiwen.com/subject/jmlfwctx.html