2017-02-27 62 views

回答

0

你可以做到这一点使用的动画特性(带有自定义动画)。

例子:

HTML

<div id="container"> 
    <div id="animatediv"> 
    </div> 
</div> 

CSS

#container { 
    background-color: yellow; 
    display: inline-block; 
    padding: 40px; 
} 

#animatediv { 
    width: 100px; 
    height: 100px; 
    background-color: red; 
    position: relative; 
    animation-name: hideshow; 
    animation-duration: 3s; 
    animation-iteration-count: infinite; 
    animation-direction: alternate; 
} 

@keyframes hideshow { 
    0% { 
    opacity: 0; 
    } 
    100% { 
    opacity: 1; 
    } 
} 

这里有一个的jsfiddle:

https://jsfiddle.net/fabio1983/j6jj9766/

您还可以检查日是页面的更多信息:

https://www.w3schools.com/css/css3_animations.asp

+0

谢谢法比奥为例,一个补充问题如何添加一个特定的持续时间隐藏和一个为节目? – Komagain

+0

@Komagain你可以更改关键帧的百分比......检查更新的jsfiddle:https://jsfiddle.net/fabio1983/j6jj9766/2/ – Fabio