Use of custom css with variables

Use of custom css with variables

  

Hello guys,


I'm trying to pass to Css a variable that comes from outsystems, for example i have a text in a variable that is caculated and i need to give that variable to the css stylesheet, is it possible?


For the same problem is passing to css a position on the screen to locate my button.


Cheers,

Nelson Mendes

Hi,


I am not sure what you mean.

do you mean something like sass/less?


can you share an example what you want to achieve, since css is styling, so locating a button is more javascript than css.


yes i mean like sass and less.


My ideia is to use a sensor from the mobile phone (accelerometer) and change the position using css of a button.


Thanks :)


J. wrote:

Hi,


I am not sure what you mean.

do you mean something like sass/less?


can you share an example what you want to achieve, since css is styling, so locating a button is more javascript than css.



I don't think I understood as well.. Even so, here are my 2 cents.. Maybe you could use some javascript?

Hello,

Regarding your first question, you can create an expression that defines the CSS class that you're going to use, concatenating your variable. So you'd have an expression with the following value:

"<style>" +
"   .MyClass {" + 
"       background-color: " + Color + ";" + 
"   }" + 
"</style>"

Where "Color" is a variable that you can set on a screen action or preparation. Then just apply that class to the desired element.