背景放大动画

时间:2018-05-20 17:05:17

标签: css3 css-transitions css-animations

我正在尝试放大特定秒的背景图像动画。它正在发生,但它再次重置。

我在jsfiddle中创建了示例链接: https://jsfiddle.net/onlinesolution/tk6rcLdx/

我在这里缺少什么?

body:before{
  content:"";
  position:absolute;
  top:0px;
  left:0px;
  height: 100vh;
   width: 100%;
    background-image: url("http://paulmason.name/media/demos/full-screen-background-image/background.jpg");
    background-position:center center;
    background-size: 100% 100%;
    background-repeat: no-repeat;
     z-index: -9;
    -webkit-animation: zoomin 5s ease-in;
    animation: zoomin 5s ease-in;
        }

/* Zoom in Keyframes */
@-webkit-keyframes zoomin {
  0% {transform: scale(1);}
  100% {transform: scale(1.5);}
}
@keyframes zoomin {
  0% {transform: scale(1);}
  100% {transform: scale(1.5);}
} /*End of Zoom in Keyframes */

1 个答案:

答案 0 :(得分:0)

您错过了一个简单的属性:animation-fill-mode: forwards

此处添加了该属性的代码,您会发现效果正常

https://codepen.io/manAbl/pen/vjbgYK

进一步阅读:

https://devdocs.io/css/animation-fill-mode