2017-02-27 60 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