[英]Getting a background-img in a keyframe
I am trying to figure out keyframe animation and in doing so, I wanting to incorporate multiple pictures. 我正在尝试找出关键帧动画,在此过程中,我想合并多张图片。 For example, every 10% increment I will want to change out the image to show someone running.
例如,每增加10%,我将要更改图像以显示某人正在跑步。
I have tried adding in a background-img
to my demo and it will not do show the image at all. 我尝试在自己的演示中添加
background-img
,但它根本不会显示图像。 I searched for this, but the only results I found were from 2013 and they said it wasn't possible then, but I figured in three years this may have changed. 我进行了搜索,但是我发现的唯一结果是从2013年开始的,他们说当时不可能,但是我认为三年后这种情况可能已经改变。
If this is not possible, how would you recommend I change the image every 10% or so? 如果这不可能,您如何建议我每10%左右更改一次图像?
Here is what I have been trying so far: 到目前为止,这是我一直在尝试的方法:
div { width: 100px; height: 100px; background-image: url("http://optimumwebdesigns.com/images/brain.jpg"); position: relative; -webkit-animation-name: example; /* Chrome, Safari, Opera */ -webkit-animation-duration: 4s; /* Chrome, Safari, Opera */ -webkit-animation-iteration-count: 3; /* Chrome, Safari, Opera */ -webkit-animation-direction: normal; /* Chrome, Safari, Opera */ animation-name: example; animation-duration: 10s; animation-iteration-count: 3; animation-direction: normal; } /* Chrome, Safari, Opera */ @-webkit-keyframes example { 0% {background-color:red; left:0px; top:0px;} 25% {background-color:yellow; left:500px; top:0px;} 50% {background-color:blue; left:500px; top:200px;} 75% {background-color:green; left:0px; top:200px;} 100% {background-color:red; left:0px; top:0px;} } /* Standard syntax */ @keyframes example { 0% {background-color:red; left:0px; top:0px;} 25% {background-color:yellow; left:500px; top:0px;} 50% {background-color:blue; left:500px; top:200px;} 75% {background-color:green; left:0px; top:200px;} 100% {background-color:red; left:0px; top:0px;} }
<div></div>
add background-size
添加
background-size
background-repeat: no-repeat;
background-size: 100% auto;
https://jsfiddle.net/bu7tgz5y/ https://jsfiddle.net/bu7tgz5y/
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.