Doubt of how to use a Less class with RAZOR

5

I'm researching a little to implement a feature to make life easier when programming.

Is it possible to do this?

We're using VS2013 with razor .

I have the following class Less:

.minColuna(@a) {
    -webkit-min-width: @a;
    -moz-min-width: @a;
    -ms-min-width: @a;
    -o-min-width: @a;
    min-width:  @a;
}

And I can not call the method like this:

Razorcausesittobeunabletoidentify@aasavariableandbecauseofthatbuga.IalreadytrieddoingthisbyJSputtingtheclassonthetablebutitgavethesameproblem...AndI'vealreadytriedusingthis:

class="minColuna(@Html.Raw("@a"): 300px)"

But it does not take the style: /

Is it possible to work around this bug?

Or is there even something inside JQuery / JS / LESS / HTML that can do something like this for me?

    
asked by anonymous 10.08.2015 / 20:10

3 answers

2

Look at it that way. Create a class that calls its function with the value of param.

.tamanhoColuna(@x){
    min-width: @x;
}

.chamaFuncao {
  .tamanhoColuna(10px);
}

<p class="chamaFuncao"> Teste :D </p> 

Attention

You will not be able to pass the value in real time, unless you compile LESS in real time.

    
10.08.2015 / 20:41
1

Try the following:

.tamanhoColuna(@x){
    min-width: @x;
}

<p class="tamanhoColuna(@x: 200px)"> Teste :D </p> 
    
10.08.2015 / 20:22
0

This functionality already exists in HTML, it is widely known as CSS inline .

Example:

th {background-color:#444; color:#FFF;}
<table>
  <tr>
    <th style="min-width:80px;">Col 1</th>
    <th style="min-width:160px;">Col 2</th>
    <th style="min-width:320px;">Col 3</th>
    <th style="min-width:640px;">Col 4</th>
  </tr>
</table>

Note: What you are trying to do is not even trying to reinvent the wheel, but the stone. Avoid this kind of thing, but if you have not got it, here's a manual work example .

    
10.08.2015 / 21:41