css3 - Multiply css value for child nodes in LESS -


i have classes below

.item-1{   .child-item-1 {      .child-item-2 {     }   } } 

i want increase padding each child padding: (n*10)px

how can have varied number of child items , each child item want increase padding

thanks in advance help

you can define constant variable @ , multiply n number, in case need specify specific child classes need this:

@default-padding: 5px;  .item-1{   padding: @default-padding;   .child-item-1 {       padding: @default-padding*10;      .child-item-2 {        padding: @default-padding*100;     }   } } 

compiles to:

.item-1 {   padding: 5px; } .item-1 .child-item-1 {   padding: 50px; } .item-1 .child-item-1 .child-item-2 {   padding: 500px; } 

if want apply childrens can use * css selector like:

@default-padding: 5px;  .item-1{   padding: @default-padding;   & > * {       padding: @default-padding*10;      & > * {        padding: @default-padding*100;     }   } } 

compiles to:

.item-1 {   padding: 5px; } .item-1 > * {   padding: 50px; } .item-1 > * > * {   padding: 500px; } 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -