eva*_*ord 7 html css animation
尝试通过使用具有相同背景图像[svg]的两个居中div来制作从中心淡入图像的css动画,并设置其宽度和背景位置的动画.问题是,在chrome上,存在一个可怕的抖动问题(可能是通过动画步骤进行chrome循环,而不是同时进行?)
这里是jsfiddle:http://jsfiddle.net/evankford/s2uRV/4/,你可以看到左边的抖动问题(同时具有宽度动画和背景位置动画).
相关代码(对于其所在网站的一些剩余内容感到抱歉)
HTML:
<div class="underheader-wrapper uhw-title">
<div class="underheader uhleft undertitle"> </div>
<div class="underheader uhright undertitle"> </div>
</div>
Run Code Online (Sandbox Code Playgroud)
和CSS:
.undertitle {
-webkit-backface-visibility: hidden;
-webkit-transform: translateZ(0);
background-image:url(http://cereusbright.com/newsite/presskit/images/underheader.svg);
}
.underheader-wrapper {
position: relative;
margin: auto;
width:320px;
height:100px;
}
.underheader {
-webkit-backface-visibility: hidden;
position:absolute;
width: 0px;
height:100px;
opacity: 0;
background-size: 320px 60px;
background-repeat: no-repeat;
-moz-animation-delay: 3s; -webkit-animation-delay:3s;
-moz-animation-duration: 3s; -webkit-animation-duration: 3s;
-moz-animation-name: part1; -webkit-animation-name:part1;
-webkit-animation-fill-mode:forwards;
-moz-animation-fill-mode:forwards}
.uhleft {
background-position: -160px 40px;
right: 160px;
-webkit-backface-visibility: hidden;
-moz-animation-delay: 3s; -webkit-animation-delay:3s;
-moz-animation-duration: 3s; -webkit-animation-duration: 3s;
-moz-animation-name: part2; -webkit-animation-name:part2;
-webkit-animation-fill-mode:forwards;
-moz-animation-fill-mode:forwards}
.uhright {
background-position: -160px 40px;
left: 160px;}
@-webkit-keyframes part1 {
from {
width: 0px;
opacity: 0;
}
to {
width: 160px;
opacity: 1;
}}
@-webkit-keyframes part2 {
from {
background-position:-160px 40px;
width: 0px;
opacity: 0;
}
to {
width: 160px;
background-position: 0px 40px;
opacity: 1;
}}
@-moz-keyframes part1 {
from {
width: 0px;
opacity: 0;
}
to {
width: 160px;
opacity: 1;
}}
@-moz-keyframes part2 {
from {
background-position:-160px 40px;
width: 0px;
opacity: 0;
}
to {
background-position: 0px 40px;
width: 160px;
opacity: 1;
}}
Run Code Online (Sandbox Code Playgroud)
我是否坚持这种抖动?我已经做了一个JQuery版本,发现人们说CSS更干净/更顺畅,但抖动仍然发生.
好吧,没有找到使用双 div 来实现此目标的方法。相反,我做了这样的事情。
<div class="outer">
<div class="middle">
<div class"inner">
 
</div>
</div>
</div>
Run Code Online (Sandbox Code Playgroud)
然后给它们设计风格
.outer {
position: relative;
width:321px;
height:100px;
padding: 15px;
}
.middle {
text-align: center;
position: absolute;
left: 160px;
margin:auto;
background-image:url(images/underheader.svg);
background-position:center center;
background-size: 320px 70px;
background-repeat: no-repeat;
/*all the animation stuff */
}
.inner {
position: relative;
display: inline-block;
width: 0px;
height: 100px;
/* all the animation stuff */
}
Run Code Online (Sandbox Code Playgroud)
然后,我将中间的 div 从 动画left:160px到left: 0px,将内部 div 从动画width: 0px到width: 320px.,我使用了 CSS 动画,尽管它可以通过 jquery 或 CSS 转换轻松完成。