gpt4 book ai didi

html - css3动画从左向右移动然后继续从外向左移动

转载 作者:太空宇宙 更新时间:2023-11-04 12:04:23 24 4
gpt4 key购买 nike

当页面第一次加载然后从左向右移动并重新出现时,红色框出现在其容器的中间,如下图所示:

enter image description here

这是我到目前为止所做的,但它不符合上面的想法:

.box{
-webkit-animation: left-to-right 10s infinite; /* Chrome, Safari, Opera */
animation: left-to-right 10s infinite;
}

/* Chrome, Safari, Opera */
@-webkit-keyframes left-to-right {
100%{
left:-1000px
}
}

@keyframes left-to-right {
100%{
left:-1000px
}
}

页面宽度为 1280px,框宽度为 1000px。

最佳答案

你可以使用这个:

http://codepen.io/anon/pen/dPEJzm

<div id="animated-example" class="animated shake"></div>



.animated {
-webkit-animation-duration: 5s;
animation-duration: 5s;
-webkit-animation-fill-mode: both;
animation-fill-mode: both;
-webkit-animation-timing-function: linear;
animation-timing-function: linear;
animation-iteration-count:infinite;
-webkit-animation-iteration-count:infinite;
}

@-webkit-keyframes shake {
0%, 100% {-webkit-transform: translateX(0);}
10%, 30%, 50%, 70%, 90% {-webkit-transform: translateX(-50px);}
20%, 40%, 60%, 80% {-webkit-transform: translateX(50px);}
}
@keyframes shake {
0%, 100% {transform: translateX(0);}
10%, 30%, 50%, 70%, 90% {transform: translateX(-50px);}
20%, 40%, 60%, 80% {transform: translateX(50px);}
}
.shake {
-webkit-animation-name: shake;
animation-name: shake;
}
.shake {
background:red;
height:100px;
width:100px;

}

关于html - css3动画从左向右移动然后继续从外向左移动,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29485660/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com