syntax - Why isn't this LESS mixin working? -


.v-centered (@height,@width) {     width: @width;     height: @height;     position: absolute;     top: 50%;     left: 50%;     margin: (@height / 2)px 0 0 (@width / 2)px; } 

i trying make less mixin vertically centering things (the non-line-height way) -- , less mixin isn't working. have feeling has margin: (@height / 2)px 0 0 (@width / 2)px; line can't see i'm going wrong in syntax. appreciated.

it depends on how you're using it. right code assumes width , height passed in without units, width , height properties don't append unit margin property.

also, correctly center want negate margins.

.v-centered (@height, @width) {     width: @width;     height: @height;     position: absolute;     top: 50%;     left: 50%;     margin: -(@height / 2) 0 0 -(@width / 2); } 

demo


Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -

javascript - addthis share facebook and google+ url -