How to add different CSS style to every nth element, depending on n using LESS

后端 未结 2 1065
暖寄归人
暖寄归人 2021-01-18 23:06

I am trying to add different padding to subsequent elements in a div. My DOM looks pretty simple.

0
2条回答
  •  悲哀的现实
    2021-01-18 23:34

    I suppose you want to achieve a stair visually. In this case you can do it like below:

    .parent {
      line-height: 1.2em;
    }
    
    .parent>div:not(:first-child)::before {
      content: "";
      float: left;
      width: 15px; /*your padding*/
      height: calc(1.2em + 2px);
    
    }
    0
    15
    30
    45
    60
    75

提交回复
热议问题