I am looking at less.js, mixin looks like the way touching the variable in css but i am not sure if my problem is solvable using less.js.
I want to make some class with parameter, e.g. with the format
marginTop-10
or marginTop(15)
10,15 are some numbers which i can change to specify the margin top pixel, basically these numbers can be any number.and i will use these class in my paragraph class such as
<p class="marginTop(some number)">css help</p>
How can i make this happen?
You should first write your Less file, for instance as follows:
The preceding Less code will compile into the following CSS code:
After that you can use in your HTML:
Notice that you can also compile a list of classes dynamically, see also: LESS loops used to generate column classes in twitter - How do they work?
Doing that you could write the the following Less code:
outputs: