The HTML DOM Style transitionProperty property returns and modify the name of the CSS property of an element the transition effect is for in an HTML document.
Syntax
Following is the syntax −
1. Returning transitionProperty
object.transitionProperty
2. Modifying transitionProperty
object.transitionProperty = “value”
Here value can be −
Value | Explanation |
---|---|
initial | It set this property value to its default value. |
inherit | It inherits this property value from its parent element. |
all | It set transition effect on all properties. |
property | It represents the list of CSS properties. |
none | It select no property. |
Let us see an example of HTML DOM Style transitionProperty Property:
Example
<!DOCTYPE html> <html> <style> body { color: #000; height: 100vh; } .btn { background: #db133a; border: none; height: 2rem; border-radius: 2px; width: 40%; display: block; color: #fff; outline: none; cursor: pointer; margin: 1rem 0; } .circle { height: 100px; width: 100px; background-color: #db133a; } .circle:hover { height: 200px; width: 200px; border-radius: 50%; transition: all 1s; } .show { font-size: 1.2rem; margin: 1rem 0; } </style> <body> <h1>DOM Style transitionProperty Property Demo</h1> <div class='circle'></div> <button onclick="set()" class="btn">Change TransitionProperty</button> <div class="show">Now, hover on the square</div> <script> function set() { document.querySelector('.circle').style.transitionProperty = "border-radius"; } </script> </body> </html>
Output
Click on “Change TransitionProperty” button and then hover on the “red” square to see the transitionProperty effect.