這裏的鏈接到github上我的代碼:https://github.com/jtylerm/website-issues有麻煩兩個圖像從左邊和右邊滑動到中間
我建立的網站reactJS。我試着用CSS對兩個圖像進行動畫製作,但它不能正確動畫。兩幅圖像部分滑動,然後「跳」到中心。這兩個圖像需要重疊,這就是爲什麼我在CSS中列出了z-index。
我不反對使用JavaScript來動畫圖像,如果這是比使用CSS更好的解決方案。
請幫忙!
謝謝!
這裏的鏈接到github上我的代碼:https://github.com/jtylerm/website-issues有麻煩兩個圖像從左邊和右邊滑動到中間
我建立的網站reactJS。我試着用CSS對兩個圖像進行動畫製作,但它不能正確動畫。兩幅圖像部分滑動,然後「跳」到中心。這兩個圖像需要重疊,這就是爲什麼我在CSS中列出了z-index。
我不反對使用JavaScript來動畫圖像,如果這是比使用CSS更好的解決方案。
請幫忙!
謝謝!
我不確定圖像需要結束的位置,但這是如何讓它們順利滑動的示例。
要讓綠色圖像位於頂部,請將z-index: -1
分配給紫色圖像。
.from-left {
position: absolute;
left: -100px;
animation: move-right 3s ease forwards;
}
.from-right {
position: absolute;
right: -100px;
animation: move-left 3s ease forwards;
}
@keyframes move-right {
100% {
left: calc(50% - 50px);
}
}
@keyframes move-left {
100% {
right: calc(50% - 50px);
}
}
<div class="container">
<img class="from-left" src="http://placehold.it/100/00ff00">
<img class="from-right" src="http://placehold.it/100/0000ff">
</div>
歡迎的StackOverflow,你的問題應該包含一個[**最小的,完整的和可驗證的實例**](http://stackoverflow.com/help/mcve)。 – hungerstar
使用css3進行動畫。使用js切換類。 – Medda86