关于css3:css实现鼠标悬浮图片平滑缩放

23次阅读

共计 524 个字符,预计需要花费 2 分钟才能阅读完成。

应用 transform 属性实现缩放,应用 transtion 减少动画过渡成果

鼠标悬浮前:

鼠标悬浮后:

实现代码:
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <div class="img_box">
    <img src="./images/2.png" alt="">
  </div>
</body>

<style>
  .img_box{
    width: 500px;
    height: 250px;
    overflow: hidden;
  }

  img {
    width: 500px;
    height: 250px;
    transform: scale(1);
    transition: all 1s;
  }

  .img_box:hover img {transform: scale(1.2);
    transition: all 1s;
  }
</style>

</html>

正文完
 0