Pregunta

I have a class defined in my LESS partial:

.myclass
{
    border-radius: [CALCULATION: e.g. this.height + 2px];
}

I'd like to calculate the border-radius based upon the element's height (as seen in the syntactically-incorrect example above).

What I've Tried

I have a work around:

.myclass(@height)
{
    border-radius: @height + 2px;
}

The problem with the above is that myclass may be a div with a content manageable area inside of it (so the div could well grow to an arbitrary height), so I can't necessarily pass the height as a parameter to a mixin.

NOTE: I've also tried percentages, but the border radius looks skewed.

I don't want to use any javascript for this.

¿Fue útil?

Solución

Without using javascript this is not possible as your less will be pre-compiled into standard css.

If you are happy to use javascript and less.js you could use less.modifyVars() (link to docs).

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top