【发布时间】:2015-02-21 22:22:57
【问题描述】:
我正在尝试在包含背景图像的元素的 Y 轴上执行旋转。当我达到该动画的 50% 时,我想更改图像。
问题:
背景图片也是动画的
我试图在不使用 Javascript 的情况下做到这一点。
这可能吗?
代码:
.picture {
background-image: url('http://img3.wikia.nocookie.net/__cb20130216121424/adventuretimewithfinnandjake/images/2/29/Tom-cruise-funny-face.png');
display: inline-block;
vertical-align: top;
border: 5px solid red;
width: 250px;
height: 250px;
background-size: 100% 100%;
border-radius: 100%;
}
.animated {
-webkit-animation-name: turns;
animation-name: turns;
-webkit-animation-duration: 1s;
animation-duration: 1s;
-webkit-animation-fill-mode: forwards;
animation-fill-mode: forwards;
}
@-webkit-keyframes turns {
0% { background-image: url('http://img3.wikia.nocookie.net/__cb20130216121424/adventuretimewithfinnandjake/images/2/29/Tom-cruise-funny-face.png'); -webkit-transform: rotateY(0deg); }
1% { background-image: url('http://img3.wikia.nocookie.net/__cb20130216121424/adventuretimewithfinnandjake/images/2/29/Tom-cruise-funny-face.png'); }
50% { background-image: url('http://img3.wikia.nocookie.net/__cb20130216121424/adventuretimewithfinnandjake/images/2/29/Tom-cruise-funny-face.png'); }
51% { background-image: url('http://i3.mirror.co.uk/incoming/article172940.ece/alternates/s615/image-16-jim-carrey-50th-birthday-604638636.jpg'); }
100% { background-image: url('http://i3.mirror.co.uk/incoming/article172940.ece/alternates/s615/image-16-jim-carrey-50th-birthday-604638636.jpg'); -webkit-transform: rotateY(180deg); }
}
jsFiddle:http://jsfiddle.net/dmzj7cfh/1/
【问题讨论】:
-
抱歉......只是为了澄清......你想为圆圈设置动画但保持图像静止......对吗?谢谢
-
哦,是的,抱歉我的问题不是很清楚。我想保持 rotateY 属性动画,但我不想看到背景图像过渡动画。
-
你的目标浏览器是什么?
-
jsFiddle 链接应该可以在 Chrome 中使用
标签: css background-image css-animations