放大缩小css
@keyframes scaleAnimation { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } }
完整代码:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>css实现鼠标移动至图片,图片在约定时间内进行放大缩小</title> <style> .box { width: 100px; height: 100px; cursor: pointer; transition: all 0.5s; margin: 100px auto 0; background-color: #1890ff; } .box:hover { animation: scaleAnimation 1s 1; } @keyframes scaleAnimation { 0% { transform: scale(1); } 50% { transform: scale(1.2); } 100% { transform: scale(1); } } </style> </head> <body> <div class="box"></div> </body> </html>
主要是使用了css3的动画属性,如果不需要自动放大缩小,而是hover放大,离开就缩小,那么就不用animation,直接一个 transform: scale(2) 即可
标签:scale,盒子,04,05,100px,transform,缩小,css,放大 From: https://www.cnblogs.com/iuniko/p/18172442