Javascript examples for CSS Style Property:transitionDuration
The transitionDuration property sets or gets how long to complete a transition.
Value | Description |
---|---|
time | how many seconds or milliseconds to finish a transition. Default value is 0, meaning there will be no effect |
initial | Sets this property to its default value. |
inherit | Inherits this property from its parent element. |
Item | Value |
---|---|
Default Value: | 0 |
Return Value: | A String, representing the transition-duration property of an element |
CSS Version | CSS3 |
Speed up the transition effect:
<!DOCTYPE html> <html> <head> <style> #myDIV {//from w w w .j av a 2 s. co m border: 1px solid red; background-color: #EEE; width: 200px; height: 200px; overflow: auto; -webkit-transition: all 5s; /* For Safari 3.1 to 6.0 */ transition: all 5s; } #myDIV:hover { background-color: coral; width: 500px; height: 500px; padding: 100px; border-radius: 50px; } </style> </head> <body> <button onclick="myFunction()">Test</button> <div id="myDIV"> <h1>myDIV</h1> </div> <script> function myFunction() { document.getElementById("myDIV").style.WebkitTransitionDuration = "1s"; // Code for Safari 3.1 to 6.0 document.getElementById("myDIV").style.transitionDuration = "1s"; // Standard syntax } </script> </body> </html>