Animation How to - hover to trigger css transition








Question

We would like to know how to hover to trigger css transition.

Answer


<!DOCTYPE html>
<html>
<head>
<style type='text/css'>
#test {<!--from  w w w  .jav a  2 s.c o m-->
  margin: 100px;
  height: 200px;
  width: 200px;
  background: black;
  -webkit-transition: all 1s ease;
  -moz-transition: all 1s ease;
  -o-transition: all 1s ease;
  -ms-transition: all 1s ease;
  transition: all 1s ease;
}

#test:hover {
  background: gray;
  -webkit-transform: rotate(1080deg);
  -moz-transform: rotate(1080deg);
  -o-transform: rotate(1080deg);
  -ms-transform: rotate(1080deg);
  transform: rotate(1080deg);
  -webkit-border-radius: 100px;
  -moz-border-radius: 100px;
  border-radius: 100px;
}
</style>
</head>
<body>
  <div id="test"></div>
</body>
</html>

The code above is rendered as follows: