HTML DOM Style transitionProperty Property


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 −

ValueExplanation
initialIt set this property value to its default value.
inheritIt inherits this property value from its parent element.
allIt set transition effect on all properties.
propertyIt represents the list of CSS properties.
noneIt select no property.

Let us see an example of HTML DOM Style transitionProperty Property:

Example

Live Demo

<!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.

Updated on: 17-Feb-2021

13 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements