css3动画效果transition
每当对元素的hover设置了过渡,但没对该元素设置transition的时候,鼠标移上去的过渡是瞬间产生的,若设置了transition后,就会根据你设置的时间而缓慢运动
<!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title></title> <style type="text/css"> *{ margin: 0; padding: 0; } .box{ width: 500px; height: 400px; background: #f00; margin: 100px; } .box1{ width: 200px; height: 100px; background: skyblue; transition: 1s; } .box:hover .box1{ transform: translate(100px,50px);/*位移*/ transform: translate(100px); /*单一方向的位移*/ transform: translateX(10px);/*水平位移*/ transform: translateY(100px);/*垂直位移*/ } </style> </head> <body> <div class="box"> <div class="box1"></div> </div> </body> </html>

浙公网安备 33010602011771号