Negative variables in LESS

New to LESS, I'm trying to center a div using the following:

#form_block { display: block; position: absolute; @width: 800px; @height: 500px; width: @width; height: @height; top: 50%; left: 50%; margin-left: -@width/2 px; margin-top: -250px; 

It seems that margin-top set correctly, as the sizes are explicitly specified. But I can not perceive the negative of the variable no matter how hard I try (i.e. - (@width), -1 * @width, etc.). Any ideas? It could just be a stupid mistake.

+8
css less
source share
1 answer

I had the same problem today (with a lower value). Try:

 margin-left: -(@width/2); 

(without px )

And you should also round the value:

 margin-left: -(round(@width/2)); 
+11
source share

All Articles