2

I have a speedometer. I would like to show the speed depending on what value was entered in the textbox. Here is the demo. Here is the code, if you would like to browse. The main code where I need to update the value is.

@-webkit-keyframes rotate {
    from {-webkit-transform:rotate(0deg);}
        to {-webkit-transform:rotate(180deg);} <-- I need to update 180deg on the fly
}

In ideal situation, I need to pull this value from a database. But just wondering is there a way to update this field anyhow on the go? May be JavaScirpt?

Speedometer

Note:The demo works only in Safari and Chrome, not in firefox and IE

TheTechGuy
  • 16,560
  • 16
  • 115
  • 136
  • 1
    I think I can use jQuery to create the CSS function? – TheTechGuy Oct 03 '11 at 13:21
  • possible duplicate of [programmatically changing webkit-transformation values in animation rules](http://stackoverflow.com/questions/5105530/programmatically-changing-webkit-transformation-values-in-animation-rules) – thirtydot Oct 03 '11 at 13:25

4 Answers4

1

You can define the syle hardcoded in the HTML file. And change it with a JS declaration in PHP. Not very strict, but it does the trick :)

Michiel
  • 7,855
  • 16
  • 61
  • 113
1

You may wish to try here for some solutions.

Seems as though you will have to write out a whole new CSS rule onto the page in Javascript. Or create numerous classes and change the class with Javascript, but this would not prove practical for you as you would need potentially 360 classes.

Community
  • 1
  • 1
Matt Derrick
  • 5,674
  • 2
  • 36
  • 52
0

You should try to use a css preprocessor like LESS.js or SASS:

http://lesscss.org/

http://sass-lang.com/

Guillaume86
  • 14,341
  • 4
  • 53
  • 53
0

My answer: No you can not.

But you can create the whole CSS using PHP. The best bet is to use PHP to generate the entire CSS esp the one you need to modify according to the user settting.

TheTechGuy
  • 16,560
  • 16
  • 115
  • 136