【发布时间】:2022-01-16 12:03:32
【问题描述】:
我已经知道如何做到这一点只有一次。但我希望当用户再次点击它时,动画会重新开始或重新开始。
我有这个:
function animation() {
document.getElementById('ExampleButton').className = 'Animation';
}
.ExampleButtonCSS {
position: fixed;
bottom: 113px;
background: rgba(0, 0, 0, 0);
color: #cfcfcf;
width: 100%;
padding-left: 20px;
}
#ExampleButton {
cursor: pointer;
font-size: 15px;
outline-color: #000;
outline-style: auto;
outline-width: 2px;
padding: 5px;
border: none;
background: rgba(0, 0, 0, 0.25);
color: #cfcfcf;
opacity: 0;
}
.Animation {
opacity: 0;
animation: inactivity 5s ease normal;
}
@keyframes inactivity {
from {
opacity: 0;
}
10% {
opacity: 1;
}
90% {
opacity: 1;
}
to {
opacity: 0;
}
}
<div class="ExampleButtonCSS">
<button id="ExampleButton" onclick="animation()">Fade in and Out</button>
</div>
那么,如果我点击它,我该怎么做
【问题讨论】:
标签: javascript html css animation button