Taking an input parameter for classes from HTML

2019-08-26 06:19发布

问题:

I have a regular css class defined in my .less stylesheet called pb-5 which stands for and contains padding-bottom: 5px. I use this class on elements when all they need is that one attribute and it's not worth making a whole class definition, and because it's cleaner than using the style attribute in HTML.

I am wondering if there is a way to take a parameter for my pb-5 class, so it becomes something like pb-@size. Then in my HTML I would be able to attach the class p5-[any number] and css would dynamically be generated to give it the amount of padding specified after the hyphen.

标签: css less