直接上代码,
如果需要过渡宽高可以写作:transition-property:width,height 3s;
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<style type="text/css">
#test2{
position: absolute;
left: 10px;
top: 50px;
background: red;
width:100px;
height:100px;
}
</style>
</head>
<body>
<div id="test2" class="test2"></div>
<input type="button" onclick="test2()" value="test2">
<script type="text/javascript">
function test2()
{
document.getElementById("test2").style.transition="left 3s";
document.getElementById("test2").style.left="500px";
}
</script>
</body>
</html>