css - 将鼠标悬停在图像上方时会导致图像比例变大的问题。(我使用ease-in-out,但在“out”中它并不像我想要的那样慢)
问题描述
当我将鼠标悬停在包含图像的 div 上时,它会根据我的需要慢慢放大一点,但是,一旦我用鼠标离开该 div,图像就会回到原来的位置,而没有缓慢而平滑的过渡。为什么?
.stage:hover {
img {
transition: all .3s ease-in-out;
transform: scale(1.03);
}
}
解决方案
当您停止悬停时,img 将停止转换设置,因此它只会跳回初始比例。
尝试将过渡放在实际的 img 上:
.stage {
background-color: gray;
/* just to show the extent of the stage */
}
.stage img {
transition: all .3s ease-in-out;
}
.stage:hover img {
transform: scale(1.03);
}
<div class="stage"><img src="https://picsum.photos/id/1015/200/300"></div>
推荐阅读
- mysql - 无法在 MySQL 中存储某些汉字
- angularjs - 在angularjs中的表格内插入表格
- c++ - UWP C++ PrintTask PreviewPage 重复错误
- python - 用从一个索引到另一个索引的值填充 numpy 矩阵
- ios - iOS中带有图像和两个标题的自定义导航栏
- arrays - 按组运行顺序
- windows - 视觉工作室并链接到预编译的二进制文件(lib / dll)
- java - SVG to Image 使用 SVGSalamander 不能正确渲染 SVG
- java - 使用netbeans java计算存储在mysql数据库中的日期和当前日期之间的天数
- python-3.x - ImportError:没有名为 watchdog.observers 的模块