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

2

4 Answers 4

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 :)

Sign up to request clarification or add additional context in comments.

Comments

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.

2 Comments

You might want to update that link, at the moment it's pointing to this question :)
I got a stackoverflow exception following your link ;)
0

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

http://lesscss.org/

http://sass-lang.com/

1 Comment

less.js seems better if you want to refresh client side.
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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.