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开发者_StackOverflow 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?
Note:The demo works only in Safari and Chrome, not in firefox and IE
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 :)
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.
You should try to use a css preprocessor like LESS.js or SASS:
http://lesscss.org/
http://sass-lang.com/
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.
精彩评论