css nth-of-type All In One
nth-of-type
nth-of-type(even) & nth-of-type(2n)
n 从 1 开始 ??? n can be a number, a keyword, or a formula.
.creative-box-container {
display: flex;
flex-flow: row wrap;
align-items: center;
justify-content: flex-start;
width: calc(150px * 2 + 20px);
max-height: 170px;
overflow-y: auto;
.creative-box {
box-sizing: border-box;
width: 150px;
height: 80px;
background: #f8f8f8;
border-radius: 4px;
border: 1px dashed #ddd;
margin-right: 5px;
margin-bottom: 5px;
overflow: hidden;
&:nth-of-type(even) {
margin-right: 0;
}
// &:nth-of-type(2n) {
// margin-right: 0;
// }
}
}
refs
https://developer.mozilla.org/en-US/docs/Web/CSS/:nth-of-type
©xgqfrms 2012-2020
发布文章使用:只允许注册用户才可以访问!
原创文章,版权所有©️xgqfrms
xgqfrms