张贤健的个人网站

很宅,没有朋友约又不愿意一个人待在家;不会修电脑;游戏技能点停留在连连看前几关;不会把技术挂在嘴边;不爱穿格子衬衫;没能力轻易开发各种软件。我不是大神,只是程序员中的小学生!

css根据子元素多少类设置子元素的属性--九宫格

.moment-image-div:nth-child(n+1):nth-last-child(-n+9){
    width: 33.33%;
    float: left;
}
.moment-image-div:nth-child(1):nth-last-child(1){
    width: 100%;
}
.moment-image-div:nth-child(1):nth-last-child(2),
.moment-image-div:nth-child(2):nth-last-child(1) {
    width: 50%;
    float: left;
}

效果图:

至于高度啥的,再自行略调。

posted @ 2017-11-24 15:26  张贤健  阅读(596)  评论(0编辑  收藏  举报