我试图模仿喜欢的网站移动:http://shiz.co/和http://www.maison-vignaux.com/workCSS3动画 - 图像保持当div的宽度变化
图像显示的方式,就好像他们不动,但更多的是获得展示在一个区间。我想要这种类型的动画。现在,我的形象移动,而不是像上面的网站显示更多。
我不知道如何做到这一点。
这里是我的小提琴:https://jsfiddle.net/z7ukk6kb/(无视动画的名称)
编辑:问题是在DIV的背景位置。现在它做我想要的。
<div class="parallax-elem">
<div class="img"></div>
</div>
$('.img').addClass('slide-top');
我的CSS:
.slide-top {
-webkit-animation: slide-top 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
animation: slide-top 0.5s cubic-bezier(0.250, 0.460, 0.450, 0.940) both;
}
@keyframes slide-top {
0% {
width:0;
}
100% {
width:100%;
}
}
.parallax-elem {
overflow:hidden;
position: absolute;
height:600px;
width:100%;
}
.parallax-elem:after {
content:"";
background-color:#eee;
width:100%;
height:100%;
top:0;
left:0;
right:0;
position: absolute;
z-index:10;
}
.img {
background:url('http://media.nj.com/entertainment_impact_dining/photo/coffee-stock-photo-0e8b300f42157b6f.jpg') no-repeat;
background-size: cover;
background-position: center center;
position: relative;
height: 100%;
z-index:11;
width: 100%;
}
有什么问题吗? – birdspider
我该怎么做?感谢downvote。我只是想学习。我提供了我的代码和当前正在执行的动画。 – corporalpoon
参见[mcve](https://stackoverflow.com/help/mcve) - 特别是“描述问题”。它不起作用“不是问题陈述,告诉我们期望的行为应该是什么。” – birdspider