css - 将鼠标悬停在图像上时更改为另一图像?

标签 css image animation hover

基本上我想要的是能够使图像旋转 360 度并放大图像,我已经有了这两个。

我现在需要做的是,弄清楚如何实际使其旋转 360 度并放大到不同的图像,这是我拥有的 css:

.rotate img {
    -moz-transition: all 0.6s ease-in-out;
    -webkit-transition: all 0.6s ease-in-out;
    -o-transition: all 0.6s ease-in-out;
    -ms-transition: all 0.6s ease-in-out;
    transition: all 0.6s ease-in-out;
}
.rotate img:hover {
    cursor: crosshair
    -moz-transform: rotate(360deg) scale(1.25);
    -webkit-transform: rotate(360deg) scale(1.25);
    -o-transform: rotate(360deg) scale(1.25);
    -ms-transform: rotate(360deg) scale(1.25);
    transform: rotate(360deg) scale(1.25);
}

这段代码工作正常,我需要知道的是如何使它变成不同的图像。

最佳答案

如果您可以使用<div>使用背景图像而不是实际的 <img>你可以用 css 很容易地做到这一点。

<强> Working Example

.rotate {
    background: url("http://lorempixel.com/output/abstract-q-c-100-100-7.jpg") no-repeat;
    height: 100px;
    width:100px;
    -moz-transition: all 0.6s ease-in-out;
    -webkit-transition: all 0.6s ease-in-out;
    -o-transition: all 0.6s ease-in-out;
    -ms-transition: all 0.6s ease-in-out;
    transition: all 0.6s ease-in-out;
}
.rotate:hover {
    background: url("http://lorempixel.com/output/abstract-q-c-100-100-8.jpg") no-repeat;
    cursor: crosshair;
    -moz-transform: rotate(360deg) scale(1.25);
    -webkit-transform: rotate(360deg) scale(1.25);
    -o-transform: rotate(360deg) scale(1.25);
    -ms-transform: rotate(360deg) scale(1.25);
    transform: rotate(360deg) scale(1.25);
}

关于css - 将鼠标悬停在图像上时更改为另一图像?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24149933/

相关文章:

python - reshape Pandas 列以显示图像

ios - 在 CABasicAnimation 制作动画时减慢其速度

iOS 9 方向自动旋转动画不起作用,但始终在主线程上

CSS3动画错误

javascript - 带有图像的 JQM 可折叠标题

css - 带有 float LI 的 UL 底部边框未设置高度

python - 在 Python 中检索 .dpx 文件的分辨率

javascript - 使用 % 从 px 转换的 CSS 转换不起作用

python - 如何使用 python flask 从谷歌云存储服务图像

c++ - 使用正弦或余弦函数在 C/C++ 中实现 3D 烟花效果