我試圖模仿喜歡的網站移動: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