代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>金箍棒</title>
<style>
div{
position: absolute;
left: 50%;
right: 50%;
width: 20px;
height: 80px;
background-color: gold;
transition: width 10s, height 10s,background-color 10s;
-webkit-transition: width 10s, height 10s,background-color 10s;
/* 这一句指的是兼容webkit内核的浏览器 */
}
div:hover{
width: 300px;
height: 1200px;
background-color: red;
}
</style>
</head>
<body>
<div>金 <br> 箍 <br> 棒</div>
<p>鼠标移动到方块上,查看过渡效果</p>
</body>
</html>
实现效果
transition实现过渡&动画