码迷,mamicode.com
首页 > Web开发 > 详细

根据兄弟元素的数量来设置样式(CSS揭秘学习笔记)

时间:2016-05-30 10:06:32      阅读:166      评论:0      收藏:0      [点我收藏+]

标签:

CSS揭秘学习笔记

 

li.length == 4

li:first-child:nth-last-child(4),
li:first-child:nth-last-child(4) ~ li {
    /* 当列表正好包含四项时,命中所有列表项 */
}

li.length >= 4

li:first-child:nth-last-child(n+4),
li:first-child:nth-last-child(n+4) ~ li {
    /* 当列表至少包含四项时,命中所有列表项 */
}

li.length <=4 

li:first-child:nth-last-child(-n+4),
li:first-child:nth-last-child(-n+4) ~ li {
    /* 当列表最多包含四项时,命中所有列表项 */
}

 

根据兄弟元素的数量来设置样式(CSS揭秘学习笔记)

标签:

原文地址:http://www.cnblogs.com/shinfoxy/p/5541286.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!